﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
2076	order_by with related table does not work	Malcolm Tredinnick	nobody	"This came up on IRC today: if you look at the order_by query that uses the related table Blogs in http://www.djangoproject.com/documentation/db_api/#order-by-fields, it will not actually work. The SQL we produce does not join the blogs_blog table to the blogs_entry table in the SQL query, although it does put in an ""order by blogs_blog.name ASC"" bit. We need to add in the extra table to the join as well, although this requires reordering the execution in django/db/models/query.py (in the _get_sql_clause() method).

A temporary hack for the moment is {{{Entry.objects.select_related().order_by('blogs_blog.name', 'headline')}}} but that is a bit clunky.

We need a test for this, too.

(assigning to myself for now; just noting this here in case I get hit by a bus.)"	defect	closed	Database layer (models, ORM)	dev	normal	fixed	qs-rf-fixed	gary.wilson@… real.human@… arthur.case@… tom@… mark@… portland@… floguy@… django@… remco@… eliott@… pythonmailing@…	Accepted	1	0	0	1	0	0
