I am translating a django app and I would like to translate also the homepage of the django admin site.
On this page are listed the application names and the model class names. I would like to translate the model class name but I don't find how to give a user-friendly name for a model class.
Does anybody know how to do that?
Create or update a model. Run ./manage.py makemigrations <app_name> Run ./manage.py migrate to migrate everything or ./manage.py migrate <app_name> to migrate an individual app.
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.
Naming Your Models The model definition is a class, so always use CapWords convention (no underscores). E.g. User , Permission , ContentType , etc. For the model's attributes use snake_case. E.g. first_name , last_name , etc.
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.
Look at the Meta
options verbose_name
and verbose_name_plural
, both of which are translatable.
You should use the ugettext_lazy util in the Meta of all your models
from django.db import models from django.utils.translation import ugettext_lazy as _ class Book(models.Model): ... class Meta: verbose_name = _("My Book") verbose_name_plural = _("My Books")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With