Reputation: 510
In the Django administration Interface, we have our models grouped by app. Well, I known how to customize the model name:
class MyModel (models.Model):
class Meta:
verbose_name = 'My Model'
verbose_name_plural = 'My Models'
But I couldn't customize the app name. Is there any verbose_name for the apps ?
Upvotes: 9
Views: 8448
Reputation: 1787
Since django 1.7 app_label does not work. You have to follow https://docs.djangoproject.com/en/1.7/ref/applications/#for-application-authors instructions. That is:
apps.py
in your app's directoryWrite verbose name :
# myapp/apps.py
from django.apps import AppConfig
class MyAppConfig(AppConfig):
name = 'myapp'
verbose_name = "Rock ’n’ roll"
In the project's settings change INSTALLED_APPS
:
INSTALLED_APPS = [
'myapp.apps.MyAppConfig',
# ...
]
Or, you can leave myapp.apps
in INSTALLED_APPS
and make your application load this AppConfig subclass by default as follows:
# myapp/__init__.py
default_app_config = 'myapp.apps.MyAppConfig'
alles :)
Upvotes: 22
Reputation: 3488
Add app_label
attr to your MyModel
inner META
class
class MyModel (models.Model):
class Meta:
verbose_name = 'My Model'
verbose_name_plural = 'My Models'
app_label = 'wow_app_name'
Upvotes: -1
Reputation: 2174
Using the Meta class inside your model and defining the app_label there works, but most likely you will have to do that for each model in your module.
Another approach is to actually use i18n
. In your po file, if you define a msgid with your app_label you should be good.
In your app, add/edit po file *app_label > locale > ru > django.po*
#set app label string
msgid <app_label>
msgstr "Ваше приложение этикетке"
You can read more about the internationalization here and about translation here.
Upvotes: 1