A
A
Alexander Kulaga2018-08-06 23:51:40
Django
Alexander Kulaga, 2018-08-06 23:51:40

How to design such a query in django?

Application in django. There is a table of goods, one of the fields is the manufacturer. You need to get a list of manufacturers whose products appear in the table most often (10 or more times) and sort them by the number of products. It is desirable by means of python without using pure sql.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vadim Shatalov, 2018-08-07
@AlexKulaga

Proizvoditel.objects.anotate(tovar_count=Count('goods')).filter(tovar_count__gte=10).order_by('product_count')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question