我正在尝试在 db 中搜索一个项目。db 中有两个项目,但我无法以某种方式获得第二个项目。我的代码在下面,结果只是第一行,Bewertung
而不是第二行。
我的代码很简单:
locations = Location.objects.all()[:5]
bewertungs = Bewertung.objects.filter(von_location__in=locations)
为什么我在 db 中找不到第二个条目的原因是什么?我得到第一个记录bewertung
是 4,但第二个没有出现在结果中。
编辑:
这就是 Bewertung 模型。
class Bewertung(models.Model):
von_location= models.ForeignKey(Location,related_name="locations_bewertung",default="")
von_user = models.ForeignKey(User,related_name="users_bewertung",default="")
price_leistung = models.IntegerField(max_length=5,default=00)
romantic = models.IntegerField(max_length=3,default=00)
bewertung = models.IntegerField(max_length=3,default=00)
def __unicode__(self):
return self.bewertung
这些是记录: