How to explicitly set django_language in Django session?
Thanks a lot…
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you want your users to be able to specify language, make sure that
LocaleMiddlewareis enabled:Then Django will look for the user’s language preference in that order (see
get_language_from_requestin trans_real.py):request.path_info, if i18n_patterns are usedrequest.session[settings.LANGUAGE_SESSION_KEY](DEPRECATED in Django 3.0, removed in Django 4.0)request.COOKIES[settings.LANGUAGE_COOKIE_NAME]request.META['HTTP_ACCEPT_LANGUAGE'], until accepted one is foundsettings.LANGUAGE_CODE.As of Django 4.0
The most straightforward way to set language explicitly in Django session is to activate and set the cookie, see the docs:
Before Django 4.0
The most straightforward way to set language explicitly in Django session is to rewrite
request.session[settings.LANGUAGE_SESSION_KEY]: