1
0
mirror of https://github.com/django/django.git synced 2025-10-24 22:26:08 +00:00

Fixed #27402 -- Fixed incorrect LocaleMiddleware redirects with prefix_default_language=False.

This commit is contained in:
Krzysztof Urbaniak
2016-11-05 12:56:34 +01:00
committed by Tim Graham
parent ade52ef71f
commit b8a815e9df
4 changed files with 22 additions and 1 deletions

View File

@@ -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 = (