282
Use the __range
operator:
...filter(current_issue__isnull=True, created_at__range=(start_date, end_date))
- [Django]-How to get an ImageField URL within a template?
- [Django]-Django admin TabularInline – is there a good way of adding a custom html column?
- [Django]-Django: How to format a DateField's date representation?
6
If you are using a DateTimeField
, Filtering with dates won’t include items on the last day.
You need to casts the value as date:
...filter(created_at__date__range=(start_date, end_date))
- [Django]-Update only specific fields in a models.Model
- [Django]-Django 1.8 KeyError: 'manager' on relationship
- [Django]-How to pull a random record using Django's ORM?
3
two methods
.filter(created_at__range=[from_date, to_date])
another method
.filter(Q(created_at__gte=from_date)&Q(created_at__lte=to_date))
- gte means greater than equal
- lte means less than equal
- [Django]-(13: Permission denied) while connecting to upstream:[nginx]
- [Django]-How can I access environment variables directly in a Django template?
- [Django]-Sending post data from angularjs to django as JSON and not as raw content
Source:stackexchange.com