[Answer]-Django: How to get count of ValuesQuerySet?

1👍

✅

The only way I could get past this issue without making changes in the mongodb-engine was to get the count using the normal queryset. So to get the count I used

count = Model.objects.all().count()

and for the data I that wanted, I used

values = Model.objects.values('a', 'b')

0👍

Why don’t you just try len(values). That works fine

0👍

Try this:

query_list = list(query_set)
len = query_list.indexof(query_list[-1])

This method is nothing similar to len function of list. As you might know len uses loop to calculate the length but above method exploits hashing.

0👍

Your issue caused because of mongodb aggregation functions.
you can use `Model.objects.item_frequencies(‘field’)
or you can read here.

Leave a comment