1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #5789 -- Changed LocaleMiddleware session variable to '_language'.

The old 'django_language' variable will still be read from in order
to migrate users. The backwards-compatability shim will be removed in
Django 1.8.

Thanks to jdunck for the report and stugots for the initial patch.
This commit is contained in:
Bouke Haarsma
2013-10-18 13:56:32 +02:00
committed by Tim Graham
parent 8e2029f8dd
commit 0d0f4f020a
8 changed files with 58 additions and 14 deletions

View File

@@ -56,8 +56,14 @@ class LocaleMiddleware(object):
return self.response_redirect_class(language_url)
# Store language back into session if it is not present
if hasattr(request, 'session'):
request.session.setdefault('django_language', language)
if hasattr(request, 'session') and '_language' not in request.session:
# Backwards compatibility check on django_language (remove in 1.8);
# revert to: `request.session.setdefault('_language', language)`.
if 'django_language' in request.session:
request.session['_language'] = request.session['django_language']
del request.session['django_language']
else:
request.session['_language'] = language
if not (self.is_language_prefix_patterns_used()
and language_from_path):