我有一个类别模型和视频模型
Category:
name=Charfield()
Video:
name=CharField()
category=ManyToManyField()
is_live=BooleanField()
而且我想获得所有类别的视频计数,但我想排除未直播的视频。这是我的开始状态:
Category.objects.annotate(video_count=Count('video'))
# I tried this but I'm not sure if this the right way
Category.objects.exclude(video__is_liive=False)
有任何想法吗?