django-default-language is a Django middleware for setting a default language in bi/multilingual Django project.
Use the package manager pip to install django-default-language.
pip install django-default-language
MIDDLEWARE = [
# ...
'language.DefaultLanguageMiddleware',
'django.middleware.locale.LocaleMiddleware',
# ...
]
Make sure DefaultLanguageMiddleware is before LocaleMiddleware. Otherwise, Django will default to use the requesting browser's default language from the 'Accept-Language' request header (e.g. Accept-Language: fr-CH, fr;q=0.9, en;q=0.8, de;q=0.7, *;q=0.5).
LANGUAGE_CODE = 'zh-Hans' # default language
Pull requests are welcome.