departments = Departments.objects.all().extra(select={'product_count': 
    """ SELECT COUNT(*) FROM appname_department
                           JOIN appname_product
                               ON appname_product.dept_id = appname_department.id
                           JOIN appname_review 
                               ON appname_review.product_id = appname_product.id
                           WHERE appname_review.time BETWEEN '%s' AND '%s'
                       """
     % (start, end)})
Django: how to annotate queryset with count of filtered ForeignKey field?