No Such Column Error in Django App After South Migration

前端 未结 2 799
夕颜
夕颜 2020-12-07 14:43

I\'ve run into the same issue presented by the commenter here: Django South - table already exists

There was no follow-up, so I thought I\'d post a new question. I h

2条回答
  •  盖世英雄少女心
    2020-12-07 15:30

    Probably easiest way for you will be to start migrations from scratch.

    Delete all migrations/* files for the app which you try to fix. Restore your models.py to the state which is at the moment on the database (by the help of version control tools, or just comment out the new fields). Then initialize migrations:

    manage.py migrate my_app --delete-ghost-migrations
    manage.py schemamigration my_app --init
    manage.py migrate my_app --fake
    

    This will create a record in migrations of what current database structure looks like.

    Now add your changes to models.py and south will now what has changed:

    manage.py schemamigration my_app --auto
    manage.py migrate my_app
    

提交回复
热议问题