It seems that DRF's default behavior is to stringify the object returned by DateRangeField. For example, this is how an entry appears in a "dates" field which uses this field.--
"dates": "{\"bounds\": \"[)\", \"lower\": \"2019-07-19\", \"upper\": \"2019-09-14\"}",
Has anyone else experienced this behavior and/or know how to get it to preserve the object?
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-fram...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-rest-framework/7947ec40-6540-455b-b2d5-85ed176fa7dc%40googlegroups.com.
Are you talking about incoming data? If so you should be sending ISO aware date-time objects as such: 2019-05-12T16:27:34.503919-04:00If you are talking about outgoing data then you should be saving in the DB aware UTC date-times as python datetime objects.DRF will always do the right thing if you always do the above.Aware means with the time zone.Naive means without the time zone.Always always always save UTC time, but not all databases let you store the time zone.
On Thu, Aug 15, 2019 at 12:35 PM Baze Blackwood <milesblac...@gmail.com> wrote:
It seems that DRF's default behavior is to stringify the object returned by DateRangeField. For example, this is how an entry appears in a "dates" field which uses this field.--
"dates": "{\"bounds\": \"[)\", \"lower\": \"2019-07-19\", \"upper\": \"2019-09-14\"}",
Has anyone else experienced this behavior and/or know how to get it to preserve the object?
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-rest-framework/7947ec40-6540-455b-b2d5-85ed176fa7dc%40googlegroups.com.
I'm working on an application that uses integers to represent years (the client assures me months and dates will never be known or used) and am having this same problem using an IntegerRangeField.
"years_produced": "{\"bounds\": \"[)\", \"lower\": \"1935\", \"upper\": \"1946\"}",Baze, did you ever get to the bottom of your issues or, Carl, do you have any insights as to what I'm missing?Thanks, EricOn Thursday, August 15, 2019 at 10:13:05 AM UTC-7, Carl Nobile wrote:
Are you talking about incoming data? If so you should be sending ISO aware date-time objects as such: 2019-05-12T16:27:34.503919-04:00If you are talking about outgoing data then you should be saving in the DB aware UTC date-times as python datetime objects.DRF will always do the right thing if you always do the above.Aware means with the time zone.Naive means without the time zone.Always always always save UTC time, but not all databases let you store the time zone.
On Thu, Aug 15, 2019 at 12:35 PM Baze Blackwood <milesblac...@gmail.com> wrote:
It seems that DRF's default behavior is to stringify the object returned by DateRangeField. For example, this is how an entry appears in a "dates" field which uses this field.--
"dates": "{\"bounds\": \"[)\", \"lower\": \"2019-07-19\", \"upper\": \"2019-09-14\"}",
Has anyone else experienced this behavior and/or know how to get it to preserve the object?
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-fram...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-rest-framework/7947ec40-6540-455b-b2d5-85ed176fa7dc%40googlegroups.com.
---------------------------------------------------------------------------------
Carl J. Nobile (Software Engineer)
carl....@gmail.com
-------------------------------------------------------------------------------
--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-fram...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-rest-framework/38085cbf-953c-4c56-82ed-8561ac8f4576o%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-rest-framework/CAGQqDQ%2B_mzbqYfL9Cz4ApmqxaPf7MAuDF8MeWvv2rq-G2Sw0gQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-rest-framework/CAHnuXWjxh5Phetka3Un7ozZgcpcfSnewB6nhTHLdEWO_q3e6Wg%40mail.gmail.com.