Code

Ticket #12999: management_no_using.diff

File management_no_using.diff, 1.5 KB (added by lsbardel, 4 years ago)
Line 
1Index: management.py
2===================================================================
3--- management.py       (revision 12623)
4+++ management.py       (working copy)
5@@ -7,22 +7,21 @@
6     Creates content types for models in the given app, removing any model
7     entries that no longer have a matching model class.
8     """
9-    db = kwargs['db']
10     ContentType.objects.clear_cache()
11-    content_types = list(ContentType.objects.using(db).filter(app_label=app.__name__.split('.')[-2]))
12+    content_types = list(ContentType.objects.filter(app_label=app.__name__.split('.')[-2]))
13     app_models = get_models(app)
14     if not app_models:
15         return
16     for klass in app_models:
17         opts = klass._meta
18         try:
19-            ct = ContentType.objects.using(db).get(app_label=opts.app_label,
20-                                                   model=opts.object_name.lower())
21+            ct = ContentType.objects.get(app_label=opts.app_label,
22+                                         model=opts.object_name.lower())
23             content_types.remove(ct)
24         except ContentType.DoesNotExist:
25             ct = ContentType(name=smart_unicode(opts.verbose_name_raw),
26                 app_label=opts.app_label, model=opts.object_name.lower())
27-            ct.save(using=db)
28+            ct.save()
29             if verbosity >= 2:
30                 print "Adding content type '%s | %s'" % (ct.app_label, ct.model)
31     # The presence of any remaining content types means the supplied app has an