302 redirect to standard language for non-i18n URL's when returning 404.
|Reported by:||petar@…||Owned by:||jezdez|
|Severity:||Release blocker||Keywords:||urlconf, i18n|
|Cc:||brocaar, jezdez||Triage Stage:||Accepted|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I'm using [Tastypie] to supply an API for my project. This API should be a language independent URI, while some other applications have language dependent URI's. This leaves me with the following URLConf:
from django.utils.translation import ugettext_lazy as _ from django.conf.urls.defaults import patterns, include, url from django.conf.urls.i18n import i18n_patterns urlpatterns = patterns('', url(r'^api/', include(v1_api.urls)), ) urlpatterns += i18n_patterns('', url(_(r'^something/'), include('something.urls')), )
When I raise a 404 in the API, the LocaleMiddleware detects this and tries to redirect to /en/api/[..]. I think this happens because is_language_prefix_patterns_used always returns True because it loops through all the URL's in the URLConf and finds a locale URL. However, the URL for the API is not an Locale URL.
Change History (10)
comment:1 Changed 3 years ago by carljm
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Severity changed from Normal to Release blocker
- Triage Stage changed from Unreviewed to Accepted