Django2.0 added a field to the existing model to report an error.

Django2.0 adds fields to the existing model

then execute Python manage.py makemigrations appname
but execute Python manage.py migrate prompt table already exists

how to add fields to an existing model

Oct.12,2021

add parameters in the second step, run the following command:

 python manage.py migrate --fake-initial

document is as follows :

Adding migrations to new apps is straightforward - they come preconfigured to accept migrations, and so just run makemigrations once you' ve made some changes.

If your app already has models and database tables, and doesn' t have migrations yet (for example, you created it against a previous Django version), you' ll need to convert it to use migrations; this is a simple process:

$ python manage.py makemigrations your_app_label
This will make a new initial migration for your app. Now, run python manage.py migrate --fake-initial, and Django will detect that you have an initial migration and that the tables it wants to create already exist, and will mark the migration as already applied. (Without the migrate --fake-initial flag, the command would error out because the tables it wants to create already exist.)

you deleted the migration file. Please take good care of the migration documents.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e5a462-43b49.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e5a462-43b49.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?