I\'ve changed my models an then I tried to migrate them, but got this error:
python manage.py migrate
Operations to perform:
Apply all migrations: admin, conte
I had the same issue. Basically, the reason is because the migration thinks the database has those columns but the DB actually does not, so you need a procedure to delete those non-existent columns from migration records.
1.Comment those columns in your code.
2.Reset migrations.
find . -path "*/migrations/*.py" -not -name "__init__.py" -delete
find . -path "*/migrations/*.pyc" -delete
3.Do normal initial migration.
python manage.py makemigrations
python manage.py migrate
4.In your code, uncomment those duplicate columns.
python manage.py makemigrations
python manage.py migrate --fake
5.Now your migrations and code are on same page. I use fake to let migration believe DB has those column, but indeed DB does not.
6.In your code, comment those duplicate column again.
python manage.py makemigrations
python manage.py migrate
7.Here, you successfully delete those column records from migrations. And also in your code, those column are commented. They are on the same page.
8.Uncomment those columns again in your code and do migrations.
python manage.py makemigrations
python manage.py migrate
9.It should then work.
This is the only way that worked for my situation. I hope others can provide an easier approach.