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 ca
Use https://pypi.python.org/pypi/django-daterange-filter/ to use date range filter.
You can combine date and range field lookups:
queryset.filter(created_at__date__range=(start_date, end_date))
You can use __gte
(greater than or equal) and __lte
(less than or equal). For example:
queryset.filter(created_at__gte=datetime.date.today())
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))
You can use range e.g.
first_date = datetime.date(2005, 1, 1)
last_date = datetime.date(2005, 3, 31)
queryset.filter(created_at__range=(first_date, last_date))