from django.db import migrations from ishtar_common.utils_migrations import migrations_load_data def load_data(apps, __): module_name = "archaeological_operations" SiteCurrentStatusType = apps.get_model(module_name, "SiteCurrentStatusType") SiteDiscoveryStatusType = apps.get_model(module_name, "SiteDiscoveryStatusType") if not SiteDiscoveryStatusType.objects.count() or not SiteCurrentStatusType.objects.count(): json_file = "0120_data_site_status.json" migrations_load_data(module_name, json_file) NatureOfSiteType = apps.get_model("archaeological_operations", "NatureOfSiteType") if not NatureOfSiteType.objects.count(): json_file = "0120_data_site_nature.json" migrations_load_data(module_name, json_file) InterpretationLevelType = apps.get_model("archaeological_operations", "InterpretationLevelType") if not InterpretationLevelType.objects.count(): json_file = "0120_data_site_interpretation.json" migrations_load_data(module_name, json_file) SiteType = apps.get_model("archaeological_operations", "SiteType") if not SiteType.objects.count(): json_file = "0120_data_site_type.json" migrations_load_data(module_name, json_file) class Migration(migrations.Migration): dependencies = [ ('archaeological_operations', '0119_site_status_nature_interpretation'), ] operations = [ migrations.RunPython(load_data) ]