summaryrefslogtreecommitdiff
path: root/django/middleware
diff options
context:
space:
mode:
authorKrzysztof Urbaniak <urban@fail.pl>2016-11-05 12:56:34 +0100
committerTim Graham <timograham@gmail.com>2016-11-29 13:06:35 -0500
commitb8a815e9dfea89034ede7ff786551f89af84a31b (patch)
tree94621fb5141e902c0d162209e5d02adb23712da5 /django/middleware
parentade52ef71f04e57e217585358cb289098260e3ec (diff)
Fixed #27402 -- Fixed incorrect LocaleMiddleware redirects with prefix_default_language=False.
Diffstat (limited to 'django/middleware')
-rw-r--r--django/middleware/locale.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/django/middleware/locale.py b/django/middleware/locale.py
index 65a3893e9a..5643e484c6 100644
--- a/django/middleware/locale.py
+++ b/django/middleware/locale.py
@@ -35,7 +35,10 @@ class LocaleMiddleware(MiddlewareMixin):
urlconf = getattr(request, 'urlconf', settings.ROOT_URLCONF)
i18n_patterns_used, prefixed_default_language = is_language_prefix_patterns_used(urlconf)
- if response.status_code == 404 and not language_from_path and i18n_patterns_used:
+ if (response.status_code == 404 and not language_from_path and
+ i18n_patterns_used and prefixed_default_language):
+ # Maybe the language code is missing in the URL? Try adding the
+ # language prefix and redirecting to that URL.
language_path = '/%s%s' % (language, request.path_info)
path_valid = is_valid_path(language_path, urlconf)
path_needs_slash = (