django-url-filter icon indicating copy to clipboard operation
django-url-filter copied to clipboard

ISO datatime format

Open jmpmcmanus opened this issue 6 years ago • 2 comments

I am trying to query datetime, but have not been able to get it to work using iso datetime format:

api/meas/?timestamp__lte=2019-06-20T15:20:30&timestamp__gte=2019-05-12T15:20:30

Will return no data.

However, it will work if I take the T out:

api/meas/?timestamp__lte=2019-06-20 15:20:30&timestamp__gte=2019-05-12 15:20:30

which will convert it to:

api/meas/?timestamp__lte=2019-06-20%2015:20:30&timestamp__gte=2019-05-12%2015:20:30

It returns the expected data.

Is there a setting, to enable it to use iso datetime format?

Thanks Jim

jmpmcmanus avatar Nov 26 '19 18:11 jmpmcmanus

Running into the same issue here

jasonboukheir avatar Dec 30 '19 20:12 jasonboukheir

when using Django ORM, form field to validate the value is generated by the model field itself - https://github.com/miki725/django-url-filter/blob/bea478fb85fabfffeeb59bfb449afb3700047534/url_filter/filtersets/django.py#L88

for date fields, that will usually be a DateField or DateTimeField which by default honors DATE_INPUT_FORMATS or DATETIME_INPUT_FORMATS and those do not support utc by default. you can add iso format there to add iso support

miki725 avatar Dec 30 '19 20:12 miki725