overriding module caption names in django admin

随声附和 提交于 2019-12-04 21:49:46

At the moment, django doesn't provide any easy way to do this. See this ticket.

You can easily doing it through the metadata options app_label and db_table

class model_module1(models.model):
    [...]

    class Meta:
        app_label = "Cool module name"
        db_table = "module1_model"


class model_module2(models.model):
    [...]

    class Meta:
        app_label = "Cool module name"
        db_table = "module2_model"

If you configure tables names correctly you will see how your modules get grouped under the new label in the admin.

Ref: http://docs.djangoproject.com/en/dev/ref/models/options/#app-label

This solution works for Django 2:

In apps.py file:

from django.apps import AppConfig

class Config(AppConfig):
    name = 'myapp'
    verbose_name = 'My App Name'

In settings.py file:

INSTALLED_APPS = [
    'myapp.apps.Config',
]

This may help somewhat. You can change how the apps are grouped, although I don't think you can change the app name:

django-grappelli

http://code.google.com/p/django-grappelli/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!