﻿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
26195	order_by pk doesn't work in multi-table inheritance models if parent has default ordering	ris	nobody	"Using django 1.9.2, given the example models.py:

{{{
class ModelA ( models.Model ):
	class Meta ( object ):
		ordering = (""x"",)
	
	x = models.TextField ()

class ModelB ( ModelA ):
	pass
}}}

The following query should order by `modela_ptr_id`:

{{{
>>> str ( ModelB.objects.order_by ( ""pk"" ).query )
'SELECT ""dummy_modela"".""id"", ""dummy_modela"".""x"", ""dummy_modelb"".""modela_ptr_id"" FROM ""dummy_modelb"" INNER JOIN ""dummy_modela"" ON ( ""dummy_modelb"".""modela_ptr_id"" = ""dummy_modela"".""id"" ) ORDER BY ""dummy_modela"".""x"" ASC'
}}}

But doesn't, instead falling back to `ModelA`'s default.

This is particularly annoying as it prevents you from doing a `.distinct ( ""pk"" ).order_by ( ""pk"" )`"	Bug	closed	Database layer (models, ORM)	1.9	Normal	wontfix	multi table inheritance order_by MTI pk		Unreviewed	0	0	0	0	0	0
