Django 1.7 - makemigrations not detecting changes

前端 未结 29 1492
忘了有多久
忘了有多久 2020-11-27 12:43

As the title says, I can\'t seem to get migrations working.

The app was originally under 1.6, so I understand that migrations won\'t be there initially, and indeed i

29条回答
  •  清歌不尽
    2020-11-27 13:08

    ./manage makemigrations
    ./manage migrate
    

    Migrations track changes to DB so if youre changing from unmanaged to managed, you'll need to make sure that youre database table is up to date relating to the Model you're dealing with.

    If you are still in dev mode, I personally decided to delete the migration files in my IDE as well as in the django_migrations table relating to my Model and rerun the above command.

    REMEMBER: if you have a migration that ends with _001 in your IDE & _003 in your database. Django will only see if you have a migration ending with _004 for anything to update.

    The 2 (code & db migrations) are linked and work in tandem.

    Happy coding.

提交回复
热议问题