相关疑难解决方法(0)

如何在django-rest-framework查询集响应中添加注释数据?

我正在为QuerySet中的每个项生成聚合:

def get_queryset(self):
    from django.db.models import Count
    queryset = Book.objects.annotate(Count('authors'))
    return queryset
Run Code Online (Sandbox Code Playgroud)

但我没有得到JSON响应中的计数.

先感谢您.

python django django-rest-framework

37
推荐指数
3
解决办法
1万
查看次数

标签 统计

django ×1

django-rest-framework ×1

python ×1