Reset SQLite database in Django

后端 未结 5 578
孤街浪徒
孤街浪徒 2021-02-01 22:34

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 sta

5条回答
  •  再見小時候
    2021-02-01 23:04

    Do not delete your database file!

    Its correct to delete migration files and then run flush but deleting sqlite database file is wrong. This worked to me every time. If you are using other database, it will save you a lot of work and preparations.

    1. delete all ".py" and ".pyc" files manually
    2. python manage.py flush
      type "yes" to confirm
    3. python manage.py makemigrations
    4. python manage.py migrate

提交回复
热议问题