I am using django, drf and dynamic rest. I would like to filter on a date range, but there is no documentation for it.
How can we specify a date range in the url for dynamic rest?
I am using django, drf and dynamic rest. I would like to filter on a date range, but there is no documentation for it.
How can we specify a date range in the url for dynamic rest?
Answering my own question:
/api/v1/operation/?filter{date.range}[]=2012-01-01T00:00:00Z&filter{date.range}[]=2013-01-01T00:00:00Z
This will apply a range
filter on the date
field on the related model.
The date format is as supported by DateTimeField
, via parse_datetime:
datetime_re = re.compile(
r'(?P<year>\d{4})-(?P<month>\d{1,2})-(?P<day>\d{1,2})'
r'[T ](?P<hour>\d{1,2}):(?P<minute>\d{1,2})'
r'(?::(?P<second>\d{1,2})(?:\.(?P<microsecond>\d{1,6})\d{0,6})?)?'
r'(?P<tzinfo>Z|[+-]\d{2}(?::?\d{2})?)?$'
)
(which is basically an extension of ISO8601)
I do not think this datetime format is configurable at the django level. Seems to be a different thing than DATETIME_INPUT_FORMATS.