On Fri, Apr 15, 2011 at 2:44 PM, Markus T. <oberroc...@googlemail.com>wrote:

>
> I have a strange effect using pagination.
>
> I have a model with events that have a date, time, title, description
> field and so on. I display the events using pagination. In the model's
> Meta class I tell Django to order by date.
>
> I create a queryset like this:
>
> events = Event.objects.filter(date__gte=date.today())
>
> All events are there in the result. But after I apply pagination, one
> event is missing, and another event of the same date comes twice. If I
> raise the items_per_page parameter so I get only one page, all events
> are there as well.
>
> If I tell Django to order [by date, time, title], all events are
> there, using pagination or not.
>
> Can anyone explain this?


If you don't supply a total ordering, which you don't if you only specify
order by date and there are multiple events on the same date, then the
database is free to choose whatever ordering it likes for the elements not
covered by the specified ordering. It is also free to choose different
orderings for these not- fully-ordered items each time you ask it for a
portion of the overall set. Postgres in particular is prone to actually
doing this; multiple "identical" queries with the same limit/offset values
will often return different results.

Karen
-- 
http://tracey.org/kmt/

-- 
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