Ticket #13562: values-reverse-one-to-one__test-only.diff
File values-reverse-one-to-one__test-only.diff, 1008 bytes (added by , 14 years ago) |
---|
-
tests/modeltests/one_to_one/models.py
16 16 return u"%s the place" % self.name 17 17 18 18 class Restaurant(models.Model): 19 place = models.OneToOneField(Place, primary_key=True )19 place = models.OneToOneField(Place, primary_key=True, related_name='restaurant') 20 20 serves_hot_dogs = models.BooleanField() 21 21 serves_pizza = models.BooleanField() 22 22 … … 91 91 >>> r.place 92 92 <Place: Demon Dogs the place> 93 93 94 # Reverse one-to-one should work on .values() queries 95 >>> places = Place.objects.filter(pk=1).values('name', 'restaurant__serves_hot_dogs') 96 >>> places[0]['restaurant__serves_hot_dogs'] 97 True 98 94 99 # Restaurant.objects.all() just returns the Restaurants, not the Places. 95 100 # Note that there are two restaurants - Ace Hardware the Restaurant was created 96 101 # in the call to r.place = p2.