mirror of https://github.com/django/django.git
Fixed #363 - django-admin sqlall now uses database-specific initial data files if they exist.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@735 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
022a03ab32
commit
151b44c89a
|
@ -163,7 +163,18 @@ def get_sql_initial_data(mod):
|
|||
for klass in mod._MODELS:
|
||||
opts = klass._meta
|
||||
# Add custom SQL, if it's available.
|
||||
sql_file_name = os.path.join(app_dir, opts.module_name + '.sql')
|
||||
from django.core import db
|
||||
|
||||
# Get the sql file name for the init data for the current database engine
|
||||
db_engine_sql_file_name = os.path.join(app_dir, opts.module_name + '.' + db.DATABASE_ENGINE.lower() + '.sql')
|
||||
|
||||
# Check if the data specific file exists
|
||||
if os.path.exists(db_engine_sql_file_name):
|
||||
sql_file_name = db_engine_sql_file_name
|
||||
# if the database specific file doesn't exist, use the database agnostic version
|
||||
else:
|
||||
sql_file_name = os.path.join(app_dir, opts.module_name + '.sql')
|
||||
|
||||
if os.path.exists(sql_file_name):
|
||||
fp = open(sql_file_name, 'r')
|
||||
output.append(fp.read())
|
||||
|
|
Loading…
Reference in New Issue