Ticket #12286: t12286.diff

File t12286.diff, 1.5 KB (added by Russell Keith-Magee, 15 years ago)

Possible fix for syncdb problems with proxy models?

  • django/core/management/commands/syncdb.py

    diff -r fb3f48c88681 django/core/management/commands/syncdb.py
    a b  
    66from django.core.management.color import no_style
    77from django.core.management.sql import custom_sql_for_model, emit_post_sync_signal
    88from django.db import connections, router, transaction, models, DEFAULT_DB_ALIAS
     9from django.utils.datastructures import SortedDict
    910from django.utils.importlib import import_module
    1011
    1112
     
    5758        pending_references = {}
    5859
    5960        # Build the manifest of apps and models that are to be synchronized
    60         manifest = dict(
     61        all_models = [
    6162            (app.__name__.split('.')[-2],
    6263                [m for m in models.get_models(app, include_auto_created=True)
    6364                if router.allow_syncdb(db, m)])
    6465            for app in models.get_apps()
    65         )
     66        ]
    6667        def model_installed(model):
    6768            opts = model._meta
    6869            converter = connection.introspection.table_name_converter
    6970            return not ((converter(opts.db_table) in tables) or
    7071                (opts.auto_created and converter(opts.auto_created._meta.db_table) in tables))
    7172
    72         manifest = dict(
     73        manifest = SortedDict(
    7374            (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
    7576        )
    7677
    7778        # Create the tables for each model
Back to Top