Timezone aware DateTime fields in django forms -
in short, i'm trying show user datetime field initialized timezone aware datetime object, allow them edit , post back. without doing special warning non-timezone aware datetime being returned form's datetime field.
/django/db/models/fields/__init__.py:1474: runtimewarning: datetimefield mymodel.datetimefield received naive datetime (2015-09-09 15:55:00) while time zone support active.
i started reading the django time zones docs. installed pytz (pip install pytz
) , made sure use_tz = true
set.
i'm using django-easy-timezones, sets "current" timezone based on requester's ip call timezone.activate()
. understand it, setting time_zone
otherwise used default. i'm also using django-bootstrap3-datetimepicker
nice widget in form.
the timezone doesn't appear sent initial form data. instead, "current" timezone used create , send naive local datetime. this gather clean_[field]
method meant assume comes in post in "current" timezone. done automatically or meant make data timezone aware myself? if so, why might getting warning?
would make more sense send timezone , forth, having timezone aware datetime? if so, getting datetime javascript discussed here, haven't found nice way of returning datetime field format wise (especially widget not using format timezone).
Comments
Post a Comment