【发布时间】:2017-07-25 18:32:38
【问题描述】:
我想计算有问题的所有错误选择的数量。
我有很多选择的查询:
questions.annotate(choices_count=Count('choices'))
现在,当我只想将不正确的选择过滤到 Count 函数中时,它会返回:
无法将关键字“选择”解析为字段。
questions.annotate(choices_count=Count(Case(When(choice__correct=False,then=1))))
你知道怎么做吗?
【问题讨论】:
标签: python django django-1.10 django-aggregation