Blog.objects.filter(entry__pub_date__lte=date(2011, 4, 1), entry__headline__contains='Easter ').latest('pub_date')
Or Blog.objects.filter(entry__pub_date__lte=date(2011, 4, 1), entry__headline__contains='Easter ').order_by('-pub_date')[0] On Thu, Apr 21, 2011 at 10:25 PM, Carsten Fuchs <carstenfu...@t-online.de>wrote: > > I'm currently reading < > http://docs.djangoproject.com/en/1.3/topics/db/queries/#lookups-that-span-relationships > >. > > What I seem to understand is how I can find all blogs that have entries > that > - where published *sometime* before or at April 1st, > - and have the word "Easter" in the headline: > > Blog.objects.filter(entry__pub_date__lte=date(2011, 4, 1), > entry__headline__contains='Lennon') > > > What I'm wondering about is how I can find blogs whose *most recent* entry > before or at April 1st has the word "Easter" in the headline. > > Can this be expressed with the Django ORM? How? > > -- 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.