How to calculate the frequency the data appears on Django?

Asked

Viewed 39 times

0

Hi, I’m making a search bar with filters, in it the user can choose whether to sort by frequency or sort by another field (which is ordering everything right), what gives problem is when searching by frequency, that in the case will count how many times certain food was registered and will show all but ordered from the most frequent to the least frequent.

I’m trying to figure it out this way:

queryset = Compras.objects.values('comidas').annotate(c=Count('comidas')).order_by('c')

When I put to print in the terminal there appears ordered, but when I try to access the server and do the search gives the error NoReverseMatch. The can is wrong?

1 answer

0

Noreversematch is an error associated with.py urls and/or Django templates and not models. It is necessary to inform how the urls are configured and how you are using the code in the templates responsible for this search/sorting.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.