Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class UserDBConnection(object):
- """If the user is logged in (assumed if their password is in the
- session!), the global connection object is updated to use their
- connection credentials instead of the default Django ones."""
- def process_request(self, request):
- if 'password' in request.session:
- from django import db
- from django.conf import settings
- username = request.user.username
- password = request.session['password']
- db.connection.settings_dict['DATABASE_USER'] = username
- db.connection.settings_dict['DATABASE_PASSWORD'] = password
- return None
Add Comment
Please, Sign In to add comment