First, make sure you use the SessionAuthentication in Django. Put this in your settings.py
# Django rest framework
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework.authentication.SessionAuthentication'| Title | Author | Genre | Height | Publisher | |
|---|---|---|---|---|---|
| Fundamentals of Wavelets | Goswami, Jaideva | signal_processing | 228 | Wiley | |
| Data Smart | Foreman, John | data_science | 235 | Wiley | |
| God Created the Integers | Hawking, Stephen | mathematics | 197 | Penguin | |
| Superfreakonomics | Dubner, Stephen | economics | 179 | HarperCollins | |
| Orientalism | Said, Edward | history | 197 | Penguin | |
| Nature of Statistical Learning Theory, The | Vapnik, Vladimir | data_science | 230 | Springer | |
| Integration of the Indian States | Menon, V P | history | 217 | Orient Blackswan | |
| Drunkard's Walk, The | Mlodinow, Leonard | science | 197 | Penguin | |
| Image Processing & Mathematical Morphology | Shih, Frank | signal_processing | 241 | CRC |
| /* Source: http://www.boxofficemojo.com/alltime/world/ */ | |
| CREATE TABLE topmovies( | |
| Rank INTEGER, | |
| Title TEXT, | |
| Studio TEXT, | |
| Worldwide REAL, | |
| Domestic REAL, | |
| DomesticPct REAL, | |
| Overseas REAL, | |
| OverseasPct REAL, |
| { | |
| "calendar": [ | |
| { | |
| "weekday": "Monday", | |
| "title": "Art in Full Color", | |
| "description": "The first day of CAC events and exhibits is kicked off under the theme of Art in Full Color From a demonstration in graffiti art on a wall of the Rousseau Room, to the exhibit of colorful glazed modern glassware in the Dover Hall, Art in Full Color will get CAC started in full swing!", | |
| "schedule": [ | |
| { | |
| "time": "9:30-10:30am", | |
| "shortname": "LaVonne_LaRue", |
| # YOU MAY WANT TO CHECK THIS OUT: https://github.com/douglasmiranda/ddpt/blob/master/{{cookiecutter.django_project_name}}/{{cookiecutter.django_project_name}}/config/local.py | |
| # If you don't do this you will have to add the host IP in INTERNAL_IPS = ('127.0.0.1',) | |
| # And it will change, then you will have to change INTERNAL_IPS again. | |
| def show_toolbar(request): | |
| if request.is_ajax(): | |
| return False | |
| return True |
Now located at https://github.com/JeffPaine/beautiful_idiomatic_python.
Github gists don't support Pull Requests or any notifications, which made it impossible for me to maintain this (surprisingly popular) gist with fixes, respond to comments and so on. In the interest of maintaining the quality of this resource for others, I've moved it to a proper repo. Cheers!
| def not_in_student_group(user): | |
| """Use with a ``user_passes_test`` decorator to restrict access to | |
| authenticated users who are not in the "Student" group.""" | |
| return user.is_authenticated() and not user.groups.filter(name='Student').exists() | |
| # Use the above with: | |
| @user_passes_test(not_in_student_group, login_url='/elsewhere/') | |
| def some_view(request): | |
| # ... |
The program below can take one or more plain text files as input. It works with python2 and python3.
Let's say we have two files that may contain email addresses:
foo bar
ok ideler.dennis@gmail.com sup
hey...user+123@example.com,wyd
hello world!
| #!/usr/bin/env python | |
| """ | |
| Install a package from your local pip download cache without having to touch | |
| the 'net at all. | |
| You'll need to be using a pip download cache; that is, you'll need the | |
| following in your ~/.pip/pip.cfg: | |
| [install] |
| # Template: A.html | |
| <html> | |
| <head></head> | |
| <body> | |
| {% block hello %} | |
| HELLO | |
| {% endblock %} | |
| </body> | |
| </html> |