On Jul 18, 2006, at 12:04 AM, sasha wrote:
> I must be missing something really obvious - QuerySets don't support
> negative notation, so what is then the right way of getting at the
> last
> item in the set?
Just order in the "other" direction.
For example, to get the least expensive item in your store catalog,
you could do::
StoreItem.objects.order_by("price")[0]
... and to get the most expensive item::
StoreItem.objects.order_by("-price")[0]
(More: http://www.djangoproject.com/documentation/db_api/#order-by-
fields).
Jacob
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---