Watch out for using the PK as the range like that. It's possible for that query to return 0 records.
If show_id is 10, but records with a PK of 6-9 don't exist, and records with a PK of 11-14 don't exist, you won't have any records returned. Unless, of course, that's what you want. Then carry on :) On Feb 19, 11:23 am, Sean Brant <brant.s...@gmail.com> wrote: > > 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) > > This seems to work so far. > > shows = Show.objects.filter(Q(pk__range=(show_id - 4, show_id + 4) & Q > (category=category)) > > Behind the scenes it preforms a BETWEEN query. > > Thanks to all for the help! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---