﻿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
16505	Consider a different interface for get_next_by_FOO and get_previous_by_FOO	umbrae@…	nobody	"Recently I was looking to use these methods along with a deferred query. As I quickly found out, it's impossible - in order to defer I'll have to implement all of the get_next_by logic separately. That's because these methods are tied directly to a model. You can't defer because it's not part of a manager.

I'm no django expert (yet), but I'm wondering if these methods might be better suited, in the long term, off of .objects instead - so something like the following would work:

{{{
some_blog = Blog.objects.get(pk=1)

# Get the next one by passing in a model
older_blog = Blog.objects.get_next_by_date_added(some_blog)

# Get the next one by passing in a datetime object itself
older_blog = Blog.objects.get_next_by_date_added(some_blog.date_added) 

# Get the next blog, but don't get pull out content because it's unnecessary.
deferred_older_blog = Blog.objects.defer('content').get_next_by_date_added(some_blog) 
}}}

Any thoughts here?

"	New feature	new	Database layer (models, ORM)	1.3	Normal			umbrae@…	Accepted	0	0	0	0	0	0
