How to change the default cookie name `django_language` set by `set_language()` in Django?

82 views Asked by At

I could set and use set_language() as shown below:

# "core/urls.py"

...

urlpatterns += [
    path("i18n/", include("django.conf.urls.i18n")) # Here
]

Now, I want to change the default cookie name django_language below considering the security because users can easily know that Django is used for the website:

enter image description here

So, how can I change the default cookie name django_language?

1

There are 1 answers

0
Super Kai - Kazuya Ito On

By setting LANGUAGE_COOKIE_NAME in settings.py as shown below, you can change the default cookie name django_language set by set_language():

# "core/settings.py"

LANGUAGE_COOKIE_NAME = "mylang"

Then, you can change it to mylang as shown below:

enter image description here