django filter by datetime on a range of dates
datetime, django, python
Solution
You can use range lookup. Just find the lowest and greater date and then apply it as:
queryset.filter(created_at__range=(start_date, end_date))
Problem
I have a model with field "created_at", and I have a list of dates. So, I want to get all the models that are created in the date range. How ? I know that we can compare datetime and date easily using: ``` queryset.filter(created_at__startswith=date) ``` But, I have a range of dates, so how ? Let me know for more information.