Reset SQLite database in Django


I am trying to refactor a Django project. I renamed a couple apps and added a new one, as well as shuffled some models around. I want to clear my database and migrations and start fresh, but I am not sure how to accomplish this. Here’s what I did:

rm -r myapp/migrations // I ran this for all my apps    
python flush
python makemigrations myapp // I ran this for all my apps
python migrate // This errors

I get an error:

django.db.utils.OperationalError: table "myapp_mymodel" already exists

Can anyone tell me what I might be doing wrong?

EDIT: What is the django command to delete all tables? did not work.


Delete database and delete migration files (.py and .pyc) in migrations directory of your app (don’t delete file). Then run python makemigrations app and python migrate.

Answered By – vsd

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published