Using Django's new i18n_patterns: How to fall back to the default language specified in the settings module?

I'm using the new i18n_patterns of Django 1.4:

from django.conf.urls import patterns, include, url
from django.conf.urls.i18n import i18n_patterns

from django.contrib import admin
admin.autodiscover()

urlpatterns += i18n_patterns('',
    url(r'^admin/', include(admin.site.urls)),
)

It works for every active language:

/en/admin/ # Ok
/es/admin/ # Ok

But this fails:

/admin/ # 404 Not found

How to avoid the 404 error and redirect to a language-prefixed version of the requested URL (not only the admin panel)?

Is to write a custom middleware the solution? Why this doesn't come by default in Django?

Answers


It looks like you did not enable django.middleware.locale.LocaleMiddleware.


Need Your Help

Parsing the Wikipedia Pagelink dataset

database hadoop dataset wikipedia pagerank

I downloaded the Wikipedia Pagelinks dataset (available on Wiki Dumps - http://dumps.wikimedia.org/enwiki/20140102/). I want to run PageRank algorithm on the dataset, however, I am unable to parse ...

Validation Error Style in WPF, similar to Silverlight

c# wpf silverlight styles errortemplate

By default, the Validation.ErrorTemplate in WPF is just a small red border without any ToolTip.