On Friday 12 May 2006 10:32, Malcolm Tredinnick wrote:
> Now, slicing on QuerySets is used to provide SQL's offset and limit
> functionality. So evts[1:], which you have later on in the code
> translates (approximately) to SELECT ... FROM ... WHERE ... OFFSET 1.
> On the other hand, something like evts[:5], translates to
> SELECT...FROM...WHERE...LIMIT 5 and evts[1:5] would give you both
> limit and offset.
>
> Django's implementation lets you use limit on its own (the evts[:5]
> form), or offset + limit together (evts[1:5]), but not offset on its
> own. So, evts[1:] is what's causing your error.
I just wanted to point out that Django does this because the underlying
databases have the same limitation i.e. you can't supply OFFSET without
LIMIT.
Also, coming up with a better error message than this is tricky because
the problem doesn't occur when you take the slice, but when you
evaluate the QuerySet e.g. this line is fine:
evts = evts[1:]
because you might later do:
evts = evts[:10]
which would produce a query with "OFFSET 1 LIMIT 10" when you iterate
over evts.
Luke
--
"Mistakes: It could be that the purpose of your life is only to serve
as a warning to others." (despair.com)
Luke Plant || L.Plant.98 (at) cantab.net || http://lukeplant.me.uk/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" 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-users
-~----------~----~----~----~------~----~------~--~---