这里可以利用Python的内置模块calendar来达到该目的:
now = datetime.datetime.now()
last_day_of_this_month = calendar.monthrange(now.year, now.month)[1]
start_date = datetime.date(now.year, now.month, 1)
end_date = datetime.date(now.year, now.month, last_day_of_this_month)
blog.objects.filter(published_date__range=(start_date, end_date))