3👍
the solution is to access the django_migrations table in your database and delete the migration that led to this error. Then go to the your specific app migrations folder and delete the particular migration
this is the last option if
./manage.py migrate specific_app <specific_migration_to_rollback_to>
is not working, its a common issue in django version 1.10
6👍
Just been truggling with such a deadlock myself, keep getting “ValueError: The field … was declared with a lazy reference to ‘…’, but app ‘…’ doesn’t provide model ‘…’.”.
After diving into pgadmin and removing/recovering some tables i actually found that it could also be resolved by adding a new migration that tells django that the referred model has changed:
migrations.AlterField(
model_name='...',
name='...',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='...', to='<app>.<new-model>'), <===
),
In addition i had to set dependencies across apps right, so for instance the AlterField should be dependent on the migration that created that model obviously. Don’t ask me why it did not work out-of-the-box, i just had to go through this….
Paul
- [Django]-Why does MySQL treat Japanese alphabets hiragana and katakana the same, and how can you make it compatible with Django?
- [Django]-How to use custom django templatetag with django template if statement?
1👍
My problem was that PyCharm’s refactor got a bit aggressive and changed the model reference in the actual migrations files. Reverted the changed migrations and was able to proceed.
In case this helps anybody with newer versions of Django that can usually handle model renames without issue.
- [Django]-How to use FilePond in Django project
- [Django]-Django API list with pagination – Page is not JSON serializable
- [Django]-Get local system time in Django
- [Django]-Filtering by calculated (extra()) fields
- [Django]-How do you render a django form in a view?
- [Django]-Django Channels 2.0: call Consumer's channel by its name