Activate the django application

In order for Django to track the application and at the same time create a data table for its model, we need to activate it. For this, you can edit the settings.py file and add xx.apps.xxxxConfig to the INSTALLED_APPS setting.
Among them: xx: refers to the application name under the project (the name created by the startapp command), xxxx: refers to the project name, as shown below:

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',  
    'blog.apps.BlogConfig',     # 激活应用程序
]

It is not recommended to write the following (write the application name directly):

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles', 
    'blog',     # 激活应用程序

The xxxxConfig class defines the configuration content of the application. Currently, Django understands that the application is active for the project and can load its models.

Guess you like

Origin blog.csdn.net/Erudite_x/article/details/112394167