datetime field localtime() issue
See original GitHub issueDescribe the bug Django DateTime Import
To Reproduce Import DateTime data and you’ll hit a “localtime() cannot be applied to a naive datetime”, I’ve been using the package for a while now and use the admin import page as well as a custom import page for users. Both work fine for non-datetime data.
I’ve tried this with adding with tz +00 and without 2020-07-17 7:42:39 2020-07-17 7:42:39+00
I’ve tried the DateTimeWidget where format=“%Y-%m-%d %H:%M:%S” format=“%Y-%m-%d %H:%M:%S$z” format=None
I’ve posted a SOF question regarding it https://stackoverflow.com/questions/62990575/django-import-export-datetime-naive-datetime-error
And had a convo specific to it on SOF https://chat.stackoverflow.com/rooms/218260/django-import-export
The end result seems that the issue may be in the django-import-export package.
Versions (please complete the following information):
- django-import-export==2.2.0
- Python 3.7.4
- Django==3.0.2
settings.py
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
Expected behavior I was expecting the datetime to import the dates in my csv file
Screenshots View 2 links above
Additional context View 2 links above
Issue Analytics
- State:
- Created 3 years ago
- Comments:21 (12 by maintainers)
Alex and I discussed this on SO chat. The issue seemed to be that when a naive datetime was imported via the Admin console, then it couldn’t be displayed because the
render()
method inDateTimeWidget
couldn’t handle a naive datetime. However I couldn’t reproduce this issue. I’ll do some more research, but my current thinking is that it is not a bug.Closing again - does not affect
DateWidget
because it has no TZ information.