Ticket #8270: contenttype-label.diff
File contenttype-label.diff, 1.0 KB (added by , 16 years ago) |
---|
-
django/contrib/contenttypes/models.py
old new 8 8 # This cache is shared by all the get_for_* methods. 9 9 _cache = {} 10 10 11 def get_for_app_label_and_model_name(self, app_label, model_name): 12 key = (app_label.lower(), model_name.lower()) 13 try: 14 return self.__class__._cache[key] 15 except KeyError: 16 try: 17 ct = self.get(app_label=app_label, 18 model=model_name) 19 except models.ObjectDoesNotExist: 20 ct = self.get_for_model(models.get_model(app_label, model_name)) 21 self._add_to_cache(ct) 22 return ct 23 11 24 def get_for_model(self, model): 12 25 """ 13 26 Returns the ContentType object for a given model, creating the