from django.db import migrations def _ensure_navitem_table(apps, schema_editor): try: model = apps.get_model("template_engine", "TemplateEngineNavItem") except LookupError: return existing = set(schema_editor.connection.introspection.table_names()) if model._meta.db_table not in existing: schema_editor.create_model(model) class Migration(migrations.Migration): dependencies = [ ("template_engine", "0014_alter_basehomepage_body_alter_basestandardpage_body_and_more"), ] operations = [ migrations.RunPython(_ensure_navitem_table, migrations.RunPython.noop), ]