Skip to content
Browse files

Fixed #12286 -- Corrected order of table creation in syncdb so that i…

…t doesn't cause problems with proxied models. Thanks to everyone that helped to narrow down the problem.

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent 215269b commit ffe79b097905fac4be83e30ab4de3cab98fbc723 @freakboy3742 freakboy3742 committed
Showing with 5 additions and 4 deletions.
  1. +5 −4 django/core/management/commands/
9 django/core/management/commands/
@@ -6,6 +6,7 @@
from import no_style
from 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 @@ def handle_noargs(self, **options):
pending_references = {}
# Build the manifest of apps and models that are to be synchronized
- manifest = dict(
+ all_models = [
[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

0 comments on commit ffe79b0

Please sign in to comment.
Something went wrong with that request. Please try again.