45👍
✅
The migration model is defined in django.db.migrations.recorder
. So you can should change your example code slightly:
from django.db.migrations.recorder import MigrationRecorder
latest_migration = MigrationRecorder.Migration.objects.order_by('-applied')[0]
Source:stackexchange.com