I have an application in several languages but I would like to keepthe admin site always in english. What is the best way to do this?
Thanks in advance.
this is a simple solution that worked for me.
just set the language cookie in the request to English, and add that middleware in settings.py
before LocaleMiddleware
.
the upside is that there is to no need to activate and deactivate the language, so no need to worry that is will effect other requests
from django.conf import settings
from django.http import HttpRequest
from django.utils.deprecation import MiddlewareMixin
class ForceInEnglish(MiddlewareMixin):
def process_request(self, request: HttpRequest) -> None:
if request.path.startswith("/admin"):
request.COOKIES[settings.LANGUAGE_COOKIE_NAME] = "en"