diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2010-04-27 11:51:43 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2010-04-27 11:51:43 +0000 |
| commit | ffe79b097905fac4be83e30ab4de3cab98fbc723 (patch) | |
| tree | 3fbb48a63034b6d68a03dbb6791c29e7ae53603f | |
| parent | 215269b84fbb708a4e35d7fc6e17aa0415f19c6a (diff) | |
Fixed #12286 -- Corrected order of table creation in syncdb so that it doesn't cause problems with proxied models. Thanks to everyone that helped to narrow down the problem.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@13028 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | django/core/management/commands/syncdb.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/django/core/management/commands/syncdb.py b/django/core/management/commands/syncdb.py index 1fa4d199d3..d1dd49b75e 100644 --- a/django/core/management/commands/syncdb.py +++ b/django/core/management/commands/syncdb.py @@ -6,6 +6,7 @@ from django.core.management.base import NoArgsCommand from django.core.management.color import no_style from django.core.management.sql import custom_sql_for_model, emit_post_sync_signal from django.db import connections, router, transaction, models, DEFAULT_DB_ALIAS +from django.utils.datastructures import SortedDict from django.utils.importlib import import_module @@ -57,21 +58,21 @@ class Command(NoArgsCommand): pending_references = {} # Build the manifest of apps and models that are to be synchronized - manifest = dict( + all_models = [ (app.__name__.split('.')[-2], [m for m in models.get_models(app, include_auto_created=True) if router.allow_syncdb(db, m)]) for app in models.get_apps() - ) + ] def model_installed(model): opts = model._meta converter = connection.introspection.table_name_converter return not ((converter(opts.db_table) in tables) or (opts.auto_created and converter(opts.auto_created._meta.db_table) in tables)) - manifest = dict( + manifest = SortedDict( (app_name, filter(model_installed, model_list)) - for app_name, model_list in manifest.iteritems() + for app_name, model_list in all_models ) # Create the tables for each model |
