【发布时间】:2022-01-11 13:42:38
【问题描述】:
我正在尝试使用此查询过滤一些数据,
get_members = PaymentDetails.objects.filter(participants_name=Participants.objects.filter(participants_name=Profile.objects.get(user=request.user)))
但我收到此错误精确查找的 QuerySet 值必须限制为使用切片的一个结果。我的模型看起来像这样
class Committee(models.Model):
committee_creator = models.ForeignKey(Profile, on_delete=models.CASCADE)
committee_name = models.CharField(max_length=100)
class Participants(models.Model):
participants_name = models.ForeignKey(Profile, on_delete=models.CASCADE)
participants_committee_name = models.ForeignKey(Committee, on_delete=models.CASCADE)
class PaymentDetails(models.Model):
participants_name = models.ForeignKey(Participants, on_delete=models.CASCADE)
participants_paid_status = models.BooleanField(default=False)
participants_amount_paid = models.IntegerField()
【问题讨论】: