[Answer]-How can I sort and do pagination on a filtered foreign key count?

1👍

If you simply add on the filter, it should include that filter within the aggregate. You would use the related_name of the foreign key in order to filter that part of the join.

entries = Entry.objects.annotate(
    num_votes = Count('votes')).order_by('-num_votes')

entries = entries.filter(votes__created__lte=some_date)

Leave a comment