Filtering only on Annotations in Django

后端 未结 6 2065
执念已碎
执念已碎 2020-12-13 14:13

Taking the example from: http://docs.djangoproject.com/en/dev/topics/db/aggregation/#filter-and-exclude

Publisher.objects.filter(book__rating__gt=3.0).annota         


        
6条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-13 14:51

    You can try something like:

    Book.objects.values('publisher').annotate(num_books=Count('id'))
    

提交回复
热议问题