Ticket #12286: 16329-apply-this-to-reproduce-proxy-model-inheritance-failure.diff

File 16329-apply-this-to-reproduce-proxy-model-inheritance-failure.diff, 2.2 KB (added by Aymeric Augustin, 13 years ago)
  • django/core/management/commands/syncdb.py

     
    77from django.core.management.color import no_style
    88from django.core.management.sql import custom_sql_for_model, emit_post_sync_signal
    99from django.db import connections, router, transaction, models, DEFAULT_DB_ALIAS
    10 from django.utils.datastructures import SortedDict
    1110from django.utils.importlib import import_module
    1211
    1312
     
    6362        pending_references = {}
    6463
    6564        # Build the manifest of apps and models that are to be synchronized
    66         all_models = [
     65        manifest = dict(
    6766            (app.__name__.split('.')[-2],
    6867                [m for m in models.get_models(app, include_auto_created=True)
    6968                if router.allow_syncdb(db, m)])
    7069            for app in models.get_apps()
    71         ]
    72         def model_installed(model):
    73             opts = model._meta
    74             converter = connection.introspection.table_name_converter
    75             return not ((converter(opts.db_table) in tables) or
    76                 (opts.auto_created and converter(opts.auto_created._meta.db_table) in tables))
    77 
    78         manifest = SortedDict(
    79             (app_name, filter(model_installed, model_list))
    80             for app_name, model_list in all_models
    8170        )
    8271
    8372        # Create the tables for each model
     
    8877                # Create the model's database table, if it doesn't already exist.
    8978                if verbosity >= 3:
    9079                    print "Processing %s.%s model" % (app_name, model._meta.object_name)
     80                opts = model._meta
     81                if (connection.introspection.table_name_converter(opts.db_table) in tables or
     82                    (opts.auto_created and
     83                    connection.introspection.table_name_converter(opts.auto_created._meta.db_table) in tables)):
     84                    continue
    9185                sql, references = connection.creation.sql_create_model(model, self.style, seen_models)
    9286                seen_models.add(model)
    9387                created_models.add(model)
Back to Top