Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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: http://code.djangoproject.com/svn/django/trunk@13028 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit ffe79b097905fac4be83e30ab4de3cab98fbc723 1 parent 215269b
Russell Keith-Magee authored April 27, 2010

Showing 1 changed file with 5 additions and 4 deletions. Show diff stats Hide diff stats

  1. 9  django/core/management/commands/syncdb.py
9  django/core/management/commands/syncdb.py
@@ -6,6 +6,7 @@
6 6
 from django.core.management.color import no_style
7 7
 from django.core.management.sql import custom_sql_for_model, emit_post_sync_signal
8 8
 from django.db import connections, router, transaction, models, DEFAULT_DB_ALIAS
  9
+from django.utils.datastructures import SortedDict
9 10
 from django.utils.importlib import import_module
10 11
 
11 12
 
@@ -57,21 +58,21 @@ def handle_noargs(self, **options):
57 58
         pending_references = {}
58 59
 
59 60
         # Build the manifest of apps and models that are to be synchronized
60  
-        manifest = dict(
  61
+        all_models = [
61 62
             (app.__name__.split('.')[-2],
62 63
                 [m for m in models.get_models(app, include_auto_created=True)
63 64
                 if router.allow_syncdb(db, m)])
64 65
             for app in models.get_apps()
65  
-        )
  66
+        ]
66 67
         def model_installed(model):
67 68
             opts = model._meta
68 69
             converter = connection.introspection.table_name_converter
69 70
             return not ((converter(opts.db_table) in tables) or
70 71
                 (opts.auto_created and converter(opts.auto_created._meta.db_table) in tables))
71 72
 
72  
-        manifest = dict(
  73
+        manifest = SortedDict(
73 74
             (app_name, filter(model_installed, model_list))
74  
-            for app_name, model_list in manifest.iteritems()
  75
+            for app_name, model_list in all_models
75 76
         )
76 77
 
77 78
         # Create the tables for each model

0 notes on commit ffe79b0

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