Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
Something like this:
class SessionModeMiddleware(object):
def process_request(self, request):
if 'mode' not in request.session:
request.session['mode'] = 'm'
request.session.save()
As an option, you could extend django.contrib.sessions.middleware.SessionMiddleware and use your own instead of the Django midvari. But turning it off is inconvenient.
You can write your own and connect, like the answer above. And it's ok within django.
If you don’t want magic, we write a decorator on the views and already set the key there.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question