When you say "come before this object" and "come after this object",
how is this represented in your data model? Do you have a field called
show_order where you are capturing this information? In that case you
could do something like

current_show = 5 #Presumably you get this in your request
show_range = (current_show - 4, current_show + 4)
shows = Show.objects.filter(show_order__range=show_range)


FYI I haven't tested this and my Python is not good enough that I can
guarantee my syntax.

Kevin Audleman

On Feb 18, 4:06 pm, Sean Brant <brant.s...@gmail.com> wrote:
> Is there a simple way to say get me 4 objects from model that come
> before this object and 4 that come after this object.
>
> So lets say I have a Show. I would like to know which 4 shows come
> before the current show and which 4 come after, however I must limit
> the shows based on a category type. Would slicing work for this?
>
> If this is not sure clear let me know and I will try and clarify more.
--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to