Op do, 25-05-2006 te 11:28 -0400, schreef Ian Maurer:
> Django's QuerySet handles slicing through the LIMIT and OFFSET clauses
> of the database. Since the clauses cannot handle python's "negative
> indexing" scheme, you have 2 choices:
[...]
> 2. Use an order_by method to set the reverse order and then get the
> first item, use a minus sign to denote DESC order:
>
> Foo.objects.order_by("-column")[0]
>
> The second option is FAR superior. The first solution is, IMO, totally
> unacceptable since it retrieves all of the records just to access one
> row.
Quick thought: can't the QuerySet do that itself then?
--
Jan Claeys
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---