Wednesday, February 23, 2011

Re: Querysets: returning a single item with the greatest id.

On Wed, Feb 23, 2011 at 12:57 PM, Sithembewena Lloyd Dube
<zebra05@gmail.com> wrote:
> Hi everyone,
>
> How would one fetch a single item with the largest id (or most recent date
> of creation) via the database API?
>
> --
> Regards,
> Sithembewena Lloyd Dube
>

Foo.objects.all().order_by('-pk')[0] ?

Cheers

Tom

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate