diff options
| author | Jacob Kaplan-Moss <jacob@jacobian.org> | 2005-09-29 23:23:11 +0000 |
|---|---|---|
| committer | Jacob Kaplan-Moss <jacob@jacobian.org> | 2005-09-29 23:23:11 +0000 |
| commit | 151b44c89a6c53bc5e312fd84afeedffb23a0e94 (patch) | |
| tree | 1e3d0b3a823fe8bdd10e0e945e628f73725488d2 | |
| parent | 022a03ab32e85407109f2eda68b8725679c2f040 (diff) | |
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
| -rw-r--r-- | django/core/management.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/django/core/management.py b/django/core/management.py index d494564d6b..89ffb80b59 100644 --- a/django/core/management.py +++ b/django/core/management.py @@ -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()) |
