如何在Django管理员中更改应用名称? [英] How to change app name in Django admin?
问题描述
我使用创建了
'frontend'
应用程序。/manage.pystartproject前端
I created 'frontend'
application using ./manage.py startproject frontend
但是由于某些原因,我只想在Django管理员中更改应用名称,以显示您的主页
而不是'frontend'
。
But for some reason I just want to change the app name in the Django admin to display 'Your Home Page'
instead of 'frontend'
.
该怎么做?
更新:
以下是更多详细信息:
Update: Here is the little more detail:
#settings.py
INSTALLED_APPS = (
'frontend',
)
和
#frontend/models.py
class Newpage(models.Model):
#field here
class Oldpage(models.Model):
#field here
推荐答案
是的,您可以只需在应用文件夹的 apps.py 文件中的
Yes, you can do it simply
进行更改,即可从配置类中更改verbose_name属性。例如:
in your apps.py file from your app folder change the verbose_name attribute from your config class. For example:
from django.apps import AppConfig
class FrontendConfig(AppConfig):
name = 'frontend'
verbose_name = "Your Home Page"
我对其进行了测试并在Django 1.10中工作
I test it and works in Django 1.10
更新:
在Django 3中+您应该将此添加到您的 __ init __。py
文件中(通过应用程序)
In Django 3+ you should add this in your __init__.py
file (from your app)
default_app_config = 'frontend.apps.FrontendConfig'
这篇关于如何在Django管理员中更改应用名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!