Ticket #12999: management_no_using.diff

File management_no_using.diff, 1.5 KB (added by lsbardel, 15 years ago)
  • management.py

     
    77    Creates content types for models in the given app, removing any model
    88    entries that no longer have a matching model class.
    99    """
    10     db = kwargs['db']
    1110    ContentType.objects.clear_cache()
    12     content_types = list(ContentType.objects.using(db).filter(app_label=app.__name__.split('.')[-2]))
     11    content_types = list(ContentType.objects.filter(app_label=app.__name__.split('.')[-2]))
    1312    app_models = get_models(app)
    1413    if not app_models:
    1514        return
    1615    for klass in app_models:
    1716        opts = klass._meta
    1817        try:
    19             ct = ContentType.objects.using(db).get(app_label=opts.app_label,
    20                                                    model=opts.object_name.lower())
     18            ct = ContentType.objects.get(app_label=opts.app_label,
     19                                         model=opts.object_name.lower())
    2120            content_types.remove(ct)
    2221        except ContentType.DoesNotExist:
    2322            ct = ContentType(name=smart_unicode(opts.verbose_name_raw),
    2423                app_label=opts.app_label, model=opts.object_name.lower())
    25             ct.save(using=db)
     24            ct.save()
    2625            if verbosity >= 2:
    2726                print "Adding content type '%s | %s'" % (ct.app_label, ct.model)
    2827    # The presence of any remaining content types means the supplied app has an
Back to Top