Consider this model:
class A(models.Model):
field1 = models.PositiveIntegerField()
field2 = models.PositiveIntegerField()
Your migration history knows about these two fields and any further migration will consider this model state and will make changes to this model state.
Now suppose, you remove field1 and your model becomes:
class A(models.Model):
field2 = models.PositiveIntegerField()
And in the migration, you try to use field1, django should know that field1 existed. Hence when we use apps.get_model()
, it helps django use the previous migrations history and infer about field1. Otherwise you will get an error.