If you absolutely want to use lights, just use RunPython and call_command in your data migrations.
from django.db import migrations from django.core.management import call_command def add_data(apps, schema_editor): call_command('loaddata', 'thefixture.json') def remove_data(apps, schema_editor): call_command('flush') class Migration(migrations.Migration): dependencies = [ ('roundtable', '0001_initial'), ] operations = [ migrations.RunPython( add_data, reverse_code=remove_data), ]
However, it is recommended to load data using python and Django ORM code, since you won't have to deal with integrity issues.
Source
Antwan
source share