'Set or change the DEFAULT_LANGUAGE in Django
I want the default language of my site to be Persian, not English! and DEFAULT_LANGUAGE is not working for me !
A part of my settings.py file :
LANGUAGES = (
('fa','Persian'),
('en','English'),
)
DEFAULT_LANGUAGE = 1
LANGUAGE_CODE = 'fa'
TIME_ZONE = 'Asia/Tehran'
USE_I18N = True
USE_L10N = True
USE_TZ = True
I also read these and they did not help:
Set or change the default language dynamically according to the user - Django
Django how to set the default language in the i18n_patterns?
Django: Can't change default language
Please help me. thanks!
Solution 1:[1]
Here is fastest and simplest solution. In my case Django=="3.1" https://github.com/yifaneye/django-default-language
Solution 2:[2]
In settings.py you probably have this middleware,and it takes default language as your browser's language.
'django.middleware.locale.LocaleMiddleware'
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Vladimir |
| Solution 2 | Alasgar |
