Django issue during migrations – lazy reference

For me, this error occurred, because I was swapping a ForeignKey Model from

my_field = models.ForeignKey('old.model', ...)

to

my_field = models.ForeignKey('new.model', ...)

The solution was to edit the resulting migration manually, and add the latest migration from the new app as a dependency:

class Migration(migrations.Migration):
    dependencies = [
        ('old', '0016_whatever'),
        ('new', '0002_latest_migration'),   # Add this line
    ]

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)