'Performs a COUNT() query using the current filter constraints.'

def get_count(self, using):

    obj = self.clone()
    if ((len(self.select) > 1) or self.aggregate_select or (self.distinct and self.distinct_fields)):
        from django.db.models.sql.subqueries import AggregateQuery
        subquery = obj
        subquery.clear_ordering(True)
        subquery.clear_limits()
        obj = AggregateQuery(obj.model)
        try:
            obj.add_subquery(subquery, using=using)
        except EmptyResultSet:
            return 0
    obj.add_count_column()
    number = obj.get_aggregation(using=using)[None]
    number = max(0, (number - self.low_mark))
    if (self.high_mark is not None):
        number = min(number, (self.high_mark - self.low_mark))
    return number
