Changeset 7422
- Timestamp:
- 04/14/08 20:13:52 (3 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/contrib/contenttypes/generic.py
r7228 r7422 36 36 37 37 def instance_pre_init(self, signal, sender, args, kwargs): 38 # Handle initalizing an object with the generic FK instaed of 39 # content-type/object-id fields. 38 """ 39 Handles initializing an object with the generic FK instaed of 40 content-type/object-id fields. 41 """ 40 42 if self.name in kwargs: 41 43 value = kwargs.pop(self.name) … … 44 46 45 47 def get_content_type(self, obj=None, id=None): 46 # Convenience function using get_model avoids a circular import when using this model 48 # Convenience function using get_model avoids a circular import when 49 # using this model 47 50 ContentType = get_model("contenttypes", "contenttype") 48 51 if obj: … … 62 65 except AttributeError: 63 66 rel_obj = None 64 67 65 68 # Make sure to use ContentType.objects.get_for_id() to ensure that 66 69 # lookups are cached (see ticket #5570). This takes more code than 67 # the naive ``getattr(instance, self.ct_field)``, but has better 70 # the naive ``getattr(instance, self.ct_field)``, but has better 68 71 # performance when dealing with GFKs in loops and such. 69 72 f = self.model._meta.get_field(self.ct_field)
