1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | from django.db import models
from django.core.management import call_command
def load_fixture(file_name, orm):
original_get_model = models.get_mode
def get_model_southern_style(*args):
try:
return orm['.'.join(args)]
except:
return original_get_model(*args)
models.get_model = get_model_southern_style
call_command('loaddata', file_name)
models.get_model = original_get_model
|
More like this
- extras.py for management commands by dnordberg 5 years, 9 months ago
- dumpdata/loaddata with MySQL and ForeignKeys, as django command by brondsem 4 years ago
- dumpdata/loaddata with MySQL and ForeignKeys by cmgreen 5 years, 4 months ago
- Export Django data to datestamped tarball -- choose individual models for handy packaging and archiving by fish2000 2 years, 8 months ago
- dumpdata/loaddata with MySQL and ForeignKeys (Revision 2) by cmgreen 5 years, 1 month ago
Comments