jeudi 6 juin 2019

How to filtered list of record(groupby field) in such a way filtered list contains record from each group

Consider there is a list of recordsets.

id name topic_id
1 hiii      1
2 hell     2
3 test     2
4 good   3
5 badg   4
6 byeo   4

Now I want 4 records in such a way that there is at least one record of each topic_id.

It is possible through the loop, but if by default Django ORM providing such a mechanism?




Aucun commentaire:

Enregistrer un commentaire