﻿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
16760	ORM: Manager.latest() use pk by default	freek.wiekmeijer@…	nobody	"This is a proposal for a small improvement in the ORM layer.

Context:
The Manager class I'm referring to is django.db.models.manager.Manager. It has a public method named latest() which retrieves the most recent record from the applicable database table. For example MyModel.objects.latest() returns a MyModel object.

Current behaviour:
You need to specify which database column to use for the latest() method. Either through a Meta class in the model (""get_latest_by"" option), or as a parameter in the latest() call (i.e. MyModel.objects.latest('id')).

Suggested change:
In many situations you just want the object with the highest primary key value, which is typically the latest record inserted into the table.
Change latest() to use the models primary key by default, if no ""get_latest_by"" is specified in the model and no parameter is supplied to the method call.
"	New feature	closed	Database layer (models, ORM)	1.3	Normal	wontfix			Design decision needed	0	0	0	0	0	0
