문제

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top