Changeset 7561
- Timestamp:
- 05/29/08 07:17:03 (4 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/db/models/fields/related.py
r7556 r7561 166 166 def __init__(self, related): 167 167 self.related = related 168 self.cache_name = '_%s_cache' % related. field.name168 self.cache_name = '_%s_cache' % related.get_accessor_name() 169 169 170 170 def __get__(self, instance, instance_type=None): django/trunk/tests/regressiontests/one_to_one_regress/models.py
r5876 r7561 15 15 def __unicode__(self): 16 16 return u"%s the restaurant" % self.place.name 17 18 class Bar(models.Model): 19 place = models.OneToOneField(Place) 20 serves_cocktails = models.BooleanField() 21 22 def __unicode__(self): 23 return u"%s the bar" % self.place.name 17 24 18 25 class Favorites(models.Model): … … 35 42 >>> f.restaurants.all() 36 43 [<Restaurant: Demon Dogs the restaurant>] 44 45 # Regression test for #7173: Check that the name of the cache for the 46 # reverse object is correct. 47 >>> b = Bar(place=p1, serves_cocktails=False) 48 >>> b.save() 49 >>> p1.restaurant 50 <Restaurant: Demon Dogs the restaurant> 51 >>> p1.bar 52 <Bar: Demon Dogs the bar> 37 53 """}
