Model not found in migration (apps.get_model raises LookupError)

I have the following migration (logic removed for simplicity):

def migrate_existing_discounts(apps, _): ModelA = apps.get_model('myapp', 'ModelA') ModelB = apps.get_model('myapp', 'ModelB') class Migration(migrations.Migration): dependencies = [ ('myapp', '0071_auto_20160531_1342'), ] operations = [ migrations.RunPython(migrate_existing_discounts) ] 

When it starts, the following exception occurs:

 LookupError: App 'myapp' doesn't have a 'modelb' model. 

ModelA inherits from models.Model and loads successfully. ModelB , ModelB other hand, inherits from TranslatableModel and thus breaks. I read that during the migration (2 years ago) there were problems loading abstract classes ( ticket # 21786 and ticket # 21519 ), and TranslitableModel is one of them.

I had this problem before and ended the migration using RunSQL, but I would like to know how to import the models correctly, as there should be a way.

Note. The django-hvad package has no migrations, so there are no add -ons to add.

+5
source share

All Articles