Ticket #363: managment.py.diff

File managment.py.diff, 1.0 KB (added by slashzero, 19 years ago)

patch for change

  • management.py

     
    165165    for klass in mod._MODELS:
    166166        opts = klass._meta
    167167        # Add custom SQL, if it's available.
    168         sql_file_name = os.path.join(app_dir, opts.module_name + '.sql')
     168        from django.core import db
     169       
     170        # Get the sql file name for the init data for the current database engine
     171        db_engine_sql_file_name = os.path.join(app_dir, opts.module_name + '.' + db.DATABASE_ENGINE.lower() +  '.sql')
     172
     173        # Check if the data specific file exists
     174        if os.path.exists(db_engine_sql_file_name):
     175            sql_file_name = db_engine_sql_file_name
     176        # if the database specific file doesn't exist, use the database agnostic version
     177        else:
     178            sql_file_name = os.path.join(app_dir, opts.module_name + '.sql')
     179
    169180        if os.path.exists(sql_file_name):
    170181            fp = open(sql_file_name, 'r')
    171182            output.append(fp.read())
Back to Top