how to explicitly set django_langauge in django session?
Thanks a lot...
how to explicitly set django_langauge in django session?
Thanks a lot...
If you want your users to be able to specify language, make sure that LocaleMiddleware
is enabled:
MIDDLEWARE_CLASSES = (
...
'django.middleware.locale.LocaleMiddleware',
...
)
Then Django will look for the user's language preference in that order:
request.session['django_language']
;request.COOKIES[settings.LANGUAGE_COOKIE_NAME]
;request.META['HTTP_ACCEPT_LANGUAGE']
, until accepted one is found;settings.LANGUAGE_CODE
.So the most straightforward way to set language explicitly in Django session, is to rewrite request.session['django_language']
:
def someview (request):
...
request.session['django_language'] = 'en'
...