Django 1.8+
Per the 1.8 docs (and current docs),
New applications should avoid default_app_config
. Instead they should require the dotted path to the appropriate AppConfig
subclass to be configured explicitly in INSTALLED_APPS
.
Example:
INSTALLED_APPS = [
# ...snip...
'yourapp.apps.YourAppConfig',
]
Then alter your AppConfig
as listed below.
Django 1.7
As stated by rhunwicks' comment to OP, this is now possible out of the box since Django 1.7
Taken from the docs:
# in yourapp/apps.py
from django.apps import AppConfig
class YourAppConfig(AppConfig):
name = 'yourapp'
verbose_name = 'Fancy Title'
then set the default_app_config
variable to YourAppConfig
# in yourapp/__init__.py
default_app_config = 'yourapp.apps.YourAppConfig'
Prior to Django 1.7
You can give your application a custom name by defining app_label in your model definition. But as django builds the admin page it will hash models by their app_label, so if you want them to appear in one application, you have to define this name in all models of your application.
class MyModel(models.Model):
pass
class Meta:
app_label = 'My APP name'
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…