[Answered ]-Django-mptt count items in add_related_count?

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}
)

Leave a comment