makemigrations doesn't detect changes in model

前端 未结 6 990
孤独总比滥情好
孤独总比滥情好 2021-02-13 13:57

I\'m using django 1.9.6. I recently deleted my migrations and ran migrate --run-syncdb and makemigrations my_app. Today I added a new field to one of m

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-13 14:45

    Delete every past migration files and __pycache__ files except __init__ then:

    python manage.py makemigrations yourApp 
    

    After that make sure that the db is the same as the code in model.py (remove new changes) and run next line:

    python manage.py migrate --fake-initial
    

    Now add all your changes in the model.py and run next lines:

    python manage.py makemigrations 
    python manage.py migrate
    

    Best Regards, Kristian

提交回复
热议问题