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
]
Try using RenameModel
and RenameField
. See answer here: https://stackoverflow.com/a/26241640/57952