How to query as GROUP BY in django?

前端 未结 9 1461
别跟我提以往
别跟我提以往 2020-11-22 05:40

I query a model:

Members.objects.all()

And it returns:

Eric, Salesman, X-Shop
Freddie, Manager, X2-Shop
Teddy, Salesman, X2         


        
9条回答
  •  萌比男神i
    2020-11-22 05:51

    You need to do custom SQL as exemplified in this snippet:

    Custom SQL via subquery

    Or in a custom manager as shown in the online Django docs:

    Adding extra Manager methods

提交回复
热议问题