1
As django docs say, 'django.middleware.locale.LocaleMiddleware'
should be placed between "django.contrib.sessions.middleware.SessionMiddleware"
and "django.middleware.common.CommonMiddleware"
,
It should come after SessionMiddleware, because LocaleMiddleware makes use of session data. And it should come before CommonMiddleware because CommonMiddleware needs an activated language in order to resolve the requested URL.
So your MIDDLEWARE
setting should look like this:
MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
'django.middleware.locale.LocaleMiddleware',
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware"
]
0
What version of Django do you use? The trans
HTML template tag seems not in use any more, in 4.x docs translate
is the name of the tag in the examples.
Iโd also check this too, just in case it has anything to do with the Accept-Language
HTTP header.
- [Answered ]-Issues serving static files with nginx (Django)
- [Answered ]-Django model relations and dividing models into few tables in larger project
- [Answered ]-Pip Upgrade Installs Wrong Django Version: What to do?
- [Answered ]-No module named 'Queue' when I try to start celery
Source:stackexchange.com