1

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

Django: default language i18n

Please help me. thanks!

Elman Shokri
  • 11
  • 1
  • 2
  • 2
    clear the cookies in your browser, normally once picked a language, they set a language cookie. – Willem Van Onsem Jan 17 '21 at 19:10
  • `DEFAULT_LANGUAGE` is not a Django setting. It is not in the docs. Or am I missing something? https://docs.djangoproject.com/en/4.1/ref/settings/ – allcaps Jul 06 '22 at 07:51
  • `DEFAULT_LANGUAGE` is also not in the Django source code: https://github.com/django/django/search?q=DEFAULT_LANGUAGE – allcaps Jul 06 '22 at 07:53

3 Answers3

2

In settings.py you probably have this middleware,and it takes default language as your browser's language.

'django.middleware.locale.LocaleMiddleware'
Alasgar
  • 134
  • 9
0

just change this: LANGUAGE_CODE = 'fa-ir'

python
django

List Of Language Code

  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 18 '23 at 07:24
-1

Here is fastest and simplest solution. In my case Django=="3.1" https://github.com/yifaneye/django-default-language

Vladimir
  • 7
  • 1
  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 03 '22 at 13:47