SoFunction
Updated on 2024-11-15

Solving an exception in Django after deleting files in the migrations folder

The migrate file records the changes for each data migration

Solution: Rebuild the database

1. Delete the database

Wrong method:

python  shell
from  import *('drop database')

The above method of deleting the database is wrong

The right way:

If you are using the default sqlite database: you can just right click and delete db.sqlite3.

If you are using another database, go to the database's console and delete the database

2. Delete the files in migrations and keep only __init__.py.

3. Updating the database

python  makemigrations
python  migrate

Above this article to solve the Django delete files in the migrations folder after the exception problem is all I have shared with you, I hope to give you a reference, and I hope you support me more.