New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Applying format_suffix_patterns breaks Django's i18n_patterns #2278
Comments
Assume this is valid against 3.0?
Regarding backporting to 2.4, see this thread: https://groups.google.com/forum/#!topic/django-rest-framework/NHcDGGPaqNw |
I have not tried 3.0. |
I can reproduce this problem with 3.x as well. |
Could you give any more detail on this? |
When initializing the LocaleMiddleware as part of the request cycle it marks the request's url as either localized or not. class LocaleMiddleware(object):
"""
This is a very simple middleware that parses a request
and decides what translation object to install in the current
thread context. This allows pages to be dynamically
translated to the language the user desires (if the language
is available, of course).
"""
def __init__(self):
self._supported_languages = SortedDict(settings.LANGUAGES)
self._is_language_prefix_patterns_used = False
for url_pattern in get_resolver(None).url_patterns:
if isinstance(url_pattern, LocaleRegexURLResolver):
self._is_language_prefix_patterns_used = True
break
# ... When applying Regardless of LocaleMiddleware it seems that |
Okay. I guess the resolution for this will be something like wrapping the return result in If you or anyone else fancies taking on a failing test pull request for this that'd be most welcome. |
I don't think I have the time for it this week. Maybe on friday but no guarantees. |
Presumably applying them the other way around will work as expected? |
Assuming that's the case then I think we can consider this a documentation issue. |
Have you verified that the code example works? I just ensured format_suffix_patterns does not apply itself on i18n_pattern's urls. |
Using i18n_patterns as the following:
Breaks the LocaleMiddleware's assumption that localized urls are resolved using the
LocaleRegexURLResolver
class resulting in:Removing the call to
format_suffix_patterns
causes the reverse method to resolve the URLs correctly.Could this be fixed and backported to 2.4?
The text was updated successfully, but these errors were encountered: