Ticket #5826: generic.diff
File generic.diff, 1.2 KB (added by , 17 years ago) |
---|
-
django/contrib/contenttypes/generic.py
49 49 50 50 def __get__(self, instance, instance_type=None): 51 51 if instance is None: 52 r aise AttributeError, u"%s must be accessed via instance" % self.name52 return self 53 53 54 54 try: 55 55 return getattr(instance, self.cache_attr) -
tests/modeltests/generic_relations/models.py
132 132 >>> [(t.tag, t.content_type, t.object_id) for t in TaggedItem.objects.all()] 133 133 [(u'clearish', <ContentType: mineral>, 1), (u'salty', <ContentType: vegetable>, 2), (u'shiny', <ContentType: animal>, 2)] 134 134 135 # Recovering the GenericForeignKey Instance and field names 136 >>> isinstance(TaggedItem.content_object, generic.GenericForeignKey) 137 True 138 >>> TaggedItem.content_object.ct_field 139 'content_type' 140 >>> TaggedItem.content_object.fk_field 141 'object_id' 142 135 143 """}