1👍
✅
You can use the extra_filters=…
parameter of the .add_related_count(…)
method [Django-doc]:
Category.objects.add_related_count(
Category.objects.filter(is_public=True),
Question,
'category',
'question_counts',
cumulative=True,
extra_filters={'is_public': True}
)
Source:stackexchange.com