Forked from vstoykov/force_default_language_middleware.py
Created
October 6, 2016 21:47
-
-
Save alexander-ae/3907a139de98fe9212ce835a42ccb9cc to your computer and use it in GitHub Desktop.
Force django to use settings.LANGUAGE_CODE for default language and not use equest.META['HTTP_ACCEPT_LANGUAGE']
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ForceDefaultLanguageMiddleware(object): | |
""" | |
Ignore Accept-Language HTTP headers | |
This will force the I18N machinery to always choose settings.LANGUAGE_CODE | |
as the default initial language, unless another one is set via sessions or cookies | |
Should be installed *before* any middleware that checks request.META['HTTP_ACCEPT_LANGUAGE'], | |
namely django.middleware.locale.LocaleMiddleware | |
""" | |
def process_request(self, request): | |
if request.META.has_key('HTTP_ACCEPT_LANGUAGE'): | |
del request.META['HTTP_ACCEPT_LANGUAGE'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment