0

Hope You Are Good

I Have This Model:

class Task(models.Model):
    ....
    timestamp = models.DateField(auto_now_add=True)

now I want to get only September tasks

not matter what date is, I want to filter or grep September 2020 tasks

how can I achieve this?

1 Answers1

1

You can do:

month_code = 9     # September
tasks = Task.objects.filter(timestamp__month=month_code)

Refs

Biplove Lamichhane
  • 3,995
  • 4
  • 14
  • 30