Ticket #12712: django-m2m-syncdb.diff

File django-m2m-syncdb.diff, 1.7 KB (added by Alex Gaynor, 15 years ago)
  • django/core/management/commands/syncdb.py

    diff --git a/django/core/management/commands/syncdb.py b/django/core/management/commands/syncdb.py
    index e7b4b46..f4b5396 100644
    a b class Command(NoArgsCommand):  
    6363                if router.allow_syncdb(db, m)])
    6464            for app in models.get_apps()
    6565        )
     66        def model_installed(model):
     67            opts = model._meta
     68            converter = connection.introspection.table_name_converter
     69            return not ((converter(opts.db_table) in tables) or
     70                (opts.auto_created and converter(opts.auto_created._meta.db_table) in tables))
     71       
     72        manifest = dict(
     73            (app_name, filter(model_installed, model_list))
     74            for app_name, model_list in manifest.iteritems()
     75        )
    6676
    6777        # Create the tables for each model
    6878        for app_name, model_list in manifest.items():
    class Command(NoArgsCommand):  
    7080                # Create the model's database table, if it doesn't already exist.
    7181                if verbosity >= 2:
    7282                    print "Processing %s.%s model" % (app_name, model._meta.object_name)
    73                 opts = model._meta
    74                 if (connection.introspection.table_name_converter(opts.db_table) in tables or
    75                     (opts.auto_created and
    76                     connection.introspection.table_name_converter(opts.auto_created._meta.db_table) in tables)):
    77                     continue
    7883                sql, references = connection.creation.sql_create_model(model, self.style, seen_models)
    7984                seen_models.add(model)
    8085                created_models.add(model)
Back to Top