Django's loaddata giving ValidationError on valid date
-
27-10-2019 - |
문제
I'm trying to use fixtures in Django to provide some initial data to one of my projects. The model that I want to provide this data to has a DateField named 'added'. So in the JSON file that contains my fixture, I included the following line:
"added": "2011-11-11",
When I load this file using
python manage.py loaddata test.json
I get this error
ValidationError: [u'Enter a valid date in YYYY-MM-DD format.']
so I tried using dumpdata to find out how the internal formatting is different from what I did
python manage.py dumpdata modelname > bla.json
but it contains the same line that I used:
"added": "2011-11-11",
What do I have to do to use dates in my JSON files? I really can't see where I went wrong, since my formatting is identical to what dumpdate gives me.
Nearly all of my models contain DateFields and I need the data from the fixtures to test my application.
해결책
Actually, date format in Django fixtures must be yyyy-mm-dd hh:mm:ss.
다른 팁
I had the same problem try to use 2011-11-11T16:52:11