On 30/09/2015 4:16 PM, Daniel Chen wrote:
Hi all,

A migration I was running (manage.py migrate) died in the middle. I
deleted the migration file, fixed the problem (wrong default value),
recreated the migration, and re-ran it. But now, I'm getting an
inconsistent state (error message: [Model] has no field named [field]).
When I check the database, all the old fields are there. However, when I
hop into a Django shell (manage.py shell) and check the model fields
([Model]._meta.fields), they reflect the new, post-migration state. What
is going on, and how do I fix this?

Do it again. Delete the migration. Take note of the last valid migration. Open the django_migrations table and delete the migration record(s) after the last valid migration.

makemigrations again and then migrate again to bring the database into line with your models.

BTW, the shell is looking at the model not the database.

Mike


Thanks!

--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to [email protected]
<mailto:[email protected]>.
To post to this group, send email to [email protected]
<mailto:[email protected]>.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/95f33338-c53b-497d-8dcd-a4c1e444b5c4%40googlegroups.com
<https://groups.google.com/d/msgid/django-users/95f33338-c53b-497d-8dcd-a4c1e444b5c4%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/560BD05B.80000%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.

Reply via email to