Importing DateTime Error Message:
RuntimeWarning: DateTimeField Entry.date received a naive datetime (2020-07-20 09:23:19.881763) while time zone support is active.
RuntimeWarning)
Is there a way a user can select the datetime they are in or at least import the data with +00 added? Currently, I can't seem to be able to import once I add the datetime field.
Right now I'm trying this issue solution
resources.py
class TzDateTimeWidget(DateTimeWidget):
def render(self, value, obj=None):
if settings.USE_TZ:
value = localtime(value)
return super(TzDateTimeWidget, self).render(value)
class EntryResource(resources.ModelResource):
date = fields.Field(
column_name='date',
attribute='datetime',
widget=TzDateTimeWidget(format='"%Y-%m-%d %H:%M:%S"'))
class Meta:
model = Entry
fields = ('date', 'entry_type', 'amount', 'price', 'fee', 'reg_fee', 'id',)
import_order = fields
skip_unchanged = False
report_skipped = True
csv file
2020-07-17 7:42:39,,40,14.56,0,Entry,0
2020-07-17 7:47:16,,40,14.78,0,Entry,0