Model.objects.dates('pub_date','month',
order='DESC').filter(pub_date__month__lte=date.month,
pub_date__year__lte=date.year)
Note: To explain the "lte" on month and year, we want new articles to
post the first day of each month. This is why I don't use now().
Thanks!
Stephen Mizell
The .dates() methods returns a DateQuerySet, not a QuerySet. It's
intended to be the last thing in the sequence of methods that you call.
A DateQuerySet is a subset of QuerySet, but because it's had the query
slightly altered to return only the dates, it doesn't have the full
flexibility for further actions that a QuerySet does. That might well be
biting you here.
Try doing the filtering first (since filter() returns a QuerySet) and
then calling dates() on the result. So
Model.objects.filter(....).dates(....)
Remember that method calls are evaluated left to right, so you can't
just put them in any order if they return slightly different results.
Regards,
Malcolm
Worked perfectly. I would have bet money I had tried that earlier,
but it looks like I would have lost that bet. Thanks for your help
Malcolm!
Stephen Mizell