django - Django 2.1 - 'WhereNode' 对象没有属性 'output_field' 错误
问题描述
我正在尝试过滤 ViewSet 中的一些注释,如下所示:
queryset = Confirmation.objects.values('prediction__specimen_id').annotate(
sample_id=F('target_prediction__specimen_id'),
num_selected=Count('selected', filter=Q(selected=True)),
num_validated=Count('validated', filter=Q(validated=True)),
num_has_standard=Count('has_standard', filter=Q(has_standard=True)))
但是,我收到以下错误:
'WhereNode' object has no attribute 'output_field'
根据所有指南,我的语法似乎是正确的。我正在运行 Django 2.1。知道发生了什么吗?由于分页,我不能在 Django Rest Framework 中执行此操作吗?
解决方案
看起来语法确实是问题所在。我的答案已被编辑以包含正确的代码。干杯!
推荐阅读
- ms-access - 如何在 Visual Basic 2017 中获取访问字段属性
- java - 如何在 Java 代码中折叠/展开 Eclipse 资源树(项目资源管理器)?
- dart - 在 TabBarView 中预加载选项卡
- python - 无法安装 apache superset ubuntu 18.04 甚至 ubuntu 16.04
- django - 我的 django 项目中不存在的 url 错误
- javascript - 使用 d3.nest 使用 javascript 为力有向图提取值
- c - 查找整数数组中的最小元素
- javascript - 尽管存在具有 ID 的元素,但 D3.select ID 返回 null
- spring - 我无法使用 primefaces ajax 达到我的方法
- r - 如何用不同颜色为图例的 2 个表达式着色?