Django failed to generate migration file

Purpose: Project module to generate migration file
Problem: No changes detected when executing the generation command.
First, I tried to add the registered app after the generation command, but it still didn't work.
After investigation, a process is summarized:
1. Configuration file registration application

# 请在这里加入你的自定义 APP
INSTALLED_APPS += (
    'component.esb.api',

    'rest_framework',
    'django_filters',
    'corsheaders',

    'role',
    'apps.screen',
)

2. Force generation of migrations folder by executing commands

python manage.py makemigrations --empty  screen

Although the migration file will be generated here, the contents of the migration file are all empty, which is of no use.
Delete the initial empty migration file
3. Directly execute the command to generate the migration file

python manage.py makemigrations   screen

4. If you still cannot generate the migration file, you need to check the design of the table app_label in the models file. Here you need to keep the same. When generating the migration file, find all the tables under the app application through the registered app
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_42631707/article/details/109743619