You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If timezone support is enabled in django, get_datetaken gives RuntimeWarning:
"DateTimeField Photo.taken received a naive datetime (2020-12-12 11:50:20) while time zone support is active."
And saves wrong datetime in to database.
How can I fix it?
denormalized_fields={'taken': get_datetaken}
The text was updated successfully, but these errors were encountered:
Hey, that's a very good question. The reason this error comes up is, that Django stores datetime objects as UTC and "requires" a valid timezone for every datetime object. I think there is no easy way to solve this as it looks like timezone information is most of the time not available and we cannot derive this information purely from the EXIF data; stored GPS location might be helpful. Though, I suppose, most photos are not geotagged.
I would suggest, that you implement a custom get_datetime method, which either hardcodes the timezone (eg. by using the one defined in your project) or derives it somehow from the EXIF information. Or maybe something completely different, as the correct solution to this problem depends on your use case.
Anyway, we should definitely update the documentation and suggest a "simple fix may be incorrect" fix for this issue (eg. using make_aware()).
If timezone support is enabled in django, get_datetaken gives RuntimeWarning:
"DateTimeField Photo.taken received a naive datetime (2020-12-12 11:50:20) while time zone support is active."
And saves wrong datetime in to database.
How can I fix it?
denormalized_fields={'taken': get_datetaken}
The text was updated successfully, but these errors were encountered: