On 8/14/07, James Tauber <[EMAIL PROTECTED]> wrote:
> Okay, this is the solution I came up with:
>
> http://dpaste.com/16869/

I've done some similar things to account for a get_next/get_previous
on a model where some objects aren't meant to be publicly visible, and
remembered a little-known but incredibly useful fact:

get_next_by_$FIELD and get_previous_by_$FIELD accept arbitrary lookup
arguments, which means that you can define an instance method on the
model like so:

def get_next_in_category(self, category_slug):
    return self.get_next_by_creation_time(categories__slug__exact=category_slug)

Or expand on that to loop through the categories and maybe return a
dictionary with category names as keys and the appropriate
next/previous objects as values.

-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

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

Reply via email to