Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I change Django admin language?

I have a django 1.6 site with i18n working. I can change the frontend language with a select box in the top of the template, but I don't know if there is a django app or trick to change the admin language, because it seems to store somewhere in session variable, and it keeps the first language I have used in the frontend.

like image 541
maikelpac Avatar asked Jan 30 '14 23:01

maikelpac


People also ask

How do I change the admin text in Django?

To change the admin site header text, login page, and the HTML title tag of our bookstore's instead, add the following code in urls.py . The site_header changes the Django administration text which appears on the login page and the admin site. The site_title changes the text added to the <title> of every admin page.

Can we change Django admin theme?

To do so, you will have to change the project's settings.py . Find the TEMPLATES section and modify accordingly. To override the default template you first need to access the template you want to modify from the django/contrib/admin/templates/admin directory.

How do I get to Django admin?

To login to the site, open the /admin URL (e.g. http://127.0.0.1:8000/admin ) and enter your new superuser userid and password credentials (you'll be redirected to the login page, and then back to the /admin URL after you've entered your details).


2 Answers

In your settings.py just add 'django.middleware.locale.LocaleMiddleware' to your MIDDLEWARE_CLASSES setting, making sure it appears after 'django.contrib.sessions.middleware.SessionMiddleware'.

like image 124
Edditado Avatar answered Nov 03 '22 00:11

Edditado


You can create /en/admin, /fr/admin/ and so on using i18n_patterns:

urlpatterns += i18n_patterns(
    url(r'^admin/', include(admin.site.urls)),
)

(For Django <= 1.7, you must specify a prefix, use i18n_patterns('', ... ))

like image 41
Udi Avatar answered Nov 03 '22 00:11

Udi