NOTE: This is a question I found on StackOverflow which I’ve archived here, because the answer is so effing phenomenal.
If you are not into long explanations, see [Paolo Bergantino’s answer][2].
NOTE: This is a question I found on StackOverflow which I’ve archived here, because the answer is so effing phenomenal.
If you are not into long explanations, see [Paolo Bergantino’s answer][2].
| # source: http://stackoverflow.com/questions/1317714/how-can-i-filter-a-date-of-a-datetimefield-in-django | |
| from django.utils import timezone | |
| today_min = datetime.combine(timezone.now().date(), datetime.today().time().min) | |
| today_max = datetime.combine(timezone.now().date(), datetime.today().time().max) | |
| objetcs_for_today = MyModel.objects.filter(date__range=(today_min, today_max)) |