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'Magic words:
psql -U postgresSome interesting flags (to see all, use -h or --help depending on your psql version):
-E: will describe the underlaying queries of the \ commands (cool for learning!)-l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)| docker ps | awk {' print $1 '} | tail -n+2 > tmp.txt; for line in $(cat tmp.txt); do docker kill $line; done; rm tmp.txt |
| import logging | |
| from jinja2 import BytecodeCache | |
| from redis import Redis | |
| class RedisBytecodeCache(BytecodeCache): | |
| """bytecode cache on redis for jinja2 | |
| """ | |
| def __init__(self, host='localhost', port=6379, db=0, expire=0): | |
| self._conn = Redis(host=host, port=port, db=db) |
| #!/usr/bin/env python | |
| """ | |
| Self-versioning and argument-hashing cache decorator for deterministic functions. | |
| Designed to be extensible and API-compliant with Django and Flask cache backends. | |
| For examples and caveats, see the bottom of the file. | |
| Ted Kaemming: https://github.com/tkaemming | |
| Mike Tigas: https://github.com/mtigas | |
| """ |
| # NOTE: This code was extracted from a larger class and has not been | |
| # tested in this form. Caveat emptor. | |
| import django.conf | |
| import django.contrib.auth | |
| import django.core.handlers.wsgi | |
| import django.db | |
| import django.utils.importlib | |
| import httplib | |
| import json | |
| import logging |