@Tom, thanks. I thought of ordering the QuerySet, but I was not sure whether that would default to ASC or DESC - and I was not sure how to pass parameters to influence this.
@Mike, thanks. That looks simpler to do. On Wed, Feb 23, 2011 at 3:08 PM, Mike Ramirez <gufym...@gmail.com> wrote: > On Wednesday, February 23, 2011 05:04:29 am Tom Evans wrote: > > > On Wed, Feb 23, 2011 at 12:57 PM, Sithembewena Lloyd Dube > > > > > > <zebr...@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 > > also latest()[0] > > Mike > > > http://docs.djangoproject.com/en/1.2/ref/models/querysets/#django.db.models.QuerySet.latest > > -- > > Bershere's Formula for Failure: > > There are only two kinds of people who fail: those who > > listen to nobody... and those who listen to everybody. > > -- > 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. > -- Regards, Sithembewena Lloyd Dube -- 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.