Skip to content

Instantly share code, notes, and snippets.

@vstoykov
vstoykov / force_default_language_middleware.py
Last active October 16, 2024 13:56
Force Django to use settings.LANGUAGE_CODE for default language instead of request.META['HTTP_ACCEPT_LANGUAGE']
try:
from django.utils.deprecation import MiddlewareMixin
except ImportError:
MiddlewareMixin = object
class ForceDefaultLanguageMiddleware(MiddlewareMixin):
"""
Ignore Accept-Language HTTP headers