I'm trying to import csv rows into Django models. The date format in the database I'm using is '%Y/%m/%d %H:%M:%S'
, and this is the error I get when I try to import the data:
.
.
.
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/db/models/fields/__init__.py", line 1406, in get_prep_value
value = super().get_prep_value(value)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/db/models/fields/__init__.py", line 1266, in get_prep_value
return self.to_python(value)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/db/models/fields/__init__.py", line 1388, in to_python
raise exceptions.ValidationError(
django.core.exceptions.ValidationError: ['“2013/01/01 07:57:25.689” value has an invalid format. It must be in YYYY-MM-DD HH:MM[:ss[.uuuuuu]][TZ] format.']
I have this line my settings.py: DATETIME_FORMAT = '%Y/%m/%d %H:%M:%S'
How do I change the default format to be the same format as my data? Thank you!