私はと呼ばれる基本的なモデルを持っていますRestaurant
class Restaurant(models.Model):
place = models.OneToOneField(Place, primary_key=True)
serves_pizza = models.BooleanField()
serves_hotdog = models.BooleanField()
def __unicode__(self):
return u'%s the restaurant' % self.place.name
と を使用してクエリを実行するRestaurant.objects.all()
とRestaurant.objects.get()
、前者のみが正しい 2 つの異なる結果が得られます。
# this is correct
>>> r=Restaurant.objects.all()
>>> r
[<Restaurant: Hogwarts the restaurant>, <Restaurant: Domino the restaurant>]
>>> r[0].serves_hotdog
True
# this is not correct
>>> r0=Restaurant.objects.get(pk=4556376185503744)
>>> r0.serves_hotdog
False
# although they have the same pk
>>> r0.pk == r[0].pk
True
# their property values are different
>>> r[0].serves_hotdog == r0.serves_hotdog
False
>>> r[0].serves_pizza == r0.serves_pizza
False
誰もこれに似たものを見たことがありますか?