#16505: Consider a different interface for get_next_by_FOO and 
get_previous_by_FOO
-------------------------+----------------------------------------------
 Reporter:  umbrae@…     |          Owner:  nobody
     Type:  New feature  |         Status:  new
Milestone:               |      Component:  Database layer (models, ORM)
  Version:  1.3          |       Severity:  Normal
 Keywords:               |   Triage Stage:  Unreviewed
Has patch:  0            |  Easy pickings:  0
    UI/UX:  0            |
-------------------------+----------------------------------------------
 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?

-- 
Ticket URL: <https://code.djangoproject.com/ticket/16505>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to