In Django,
I can do value(), and then distinct() to group by.
A
{
Foreign Key B
}
B
{
String name
}
However, is it possible to group using a related object’s data? I.e. In the above relation, can I group A by B’s name?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I think you can order_by on the FKey model.
Iff you can’t, You need to use the Django ORM’s Annotation API, to make a new field and you will be able to order it accordingly: