Ticket #10738: deferred_model_contenttype.diff
File deferred_model_contenttype.diff, 1.2 KB (added by , 16 years ago) |
---|
-
django/contrib/contenttypes/models.py
15 15 for the same model don't hit the database. 16 16 """ 17 17 opts = model._meta 18 key = (opts.app_label, opts.object_name.lower()) 18 if model._deferred: 19 model_name = opts.proxy_for_model._meta.object_name.lower() 20 name = smart_unicode(opts.proxy_for_model._meta.verbose_name_raw) 21 else: 22 model_name = opts.object_name.lower() 23 name = smart_unicode(opts.verbose_name_raw) 24 key = (opts.app_label, model_name) 19 25 try: 20 26 ct = self.__class__._cache[key] 21 27 except KeyError: … … 24 30 # django.utils.functional.__proxy__ object. 25 31 ct, created = self.get_or_create( 26 32 app_label = opts.app_label, 27 model = opts.object_name.lower(),28 defaults = {'name': smart_unicode(opts.verbose_name_raw)},33 model = model_name, 34 defaults = {'name': name}, 29 35 ) 30 36 self._add_to_cache(ct) 31 37