Proper fixtures loading in south data migrations

 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

  1. dumpdata/loaddata with MySQL and ForeignKeys by cmgreen 6 years, 3 months ago
  2. dumpdata/loaddata with MySQL and ForeignKeys (Revision 2) by cmgreen 6 years ago
  3. dumpdata/loaddata with MySQL and ForeignKeys, as django command by brondsem 4 years, 12 months ago
  4. JSON fixtures of Intl. country codes & dial-codes by dibau_naum_h 3 years, 8 months ago
  5. Export Django data to datestamped tarball -- choose individual models for handy packaging and archiving by fish2000 3 years, 6 months ago

Comments

(Forgotten your password?)