﻿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
6171	incorrect/missing documentation for order_by in database api	Amit Ramon <amit.ramon@…>	nobody	"The documentation for order_by in the database api reads the following:

----------
To order by a field in a different table, add the other table’s name and a dot, like so:
Entry.objects.order_by('blogs_blog.name', 'headline')
----------

However, I believe that in order to be able to sort by a field in another table, (1) the table should be related to each other with  a (foreign key) relation to the table we deal with, and (2) one has to use related_objects on this table.

For the given example, the correct code should be, assuming Entry has a ForeignKey to Blog:
Entry.objects.related_objects().order_by('blogs_blog.name', 'headline')


--- Amit



"		closed	Documentation	dev		wontfix	database		Unreviewed	0	0	0	0	0	0
