I am having some difficulties with the usage of django query. Basically I am trying to perform an inner join between Tutor_info(user,contact,etc.) and UserProfile(user,points,etc.) which is joined by the ‘user’ column. The result will be ordered by ‘points’ column in the UserProfile in the descending order producing an ordered Tutor_info object list.
I’m unsure of how to produce an ordering of the Tutor_info list using an attribute on another table–UserProfile table.
Should I be doing something as follows?
tutors_list = Tutor_info.objects.all()
for t in tutors_list:
UserProfile.objects.filter(user=t.user)
???
Django does the inner join implicitly if you try to filter/order by on a foreign column. So this will work:
Or this if you join through the
auth.Usermodel (thanks to Daniel Roseman):