Ticket #13562: values-reverse-one-to-one__test-only.diff

File values-reverse-one-to-one__test-only.diff, 1008 bytes (added by Ben Davis, 15 years ago)

Patch for test that should pass.

  • tests/modeltests/one_to_one/models.py

     
    1616        return u"%s the place" % self.name
    1717
    1818class Restaurant(models.Model):
    19     place = models.OneToOneField(Place, primary_key=True)
     19    place = models.OneToOneField(Place, primary_key=True, related_name='restaurant')
    2020    serves_hot_dogs = models.BooleanField()
    2121    serves_pizza = models.BooleanField()
    2222
     
    9191>>> r.place
    9292<Place: Demon Dogs the place>
    9393
     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']
     97True
     98
    9499# Restaurant.objects.all() just returns the Restaurants, not the Places.
    95100# Note that there are two restaurants - Ace Hardware the Restaurant was created
    96101# in the call to r.place = p2.
Back to Top