When I run:
django-admin.py loaddata ../data/library_authors.json
the error is:
...
ValidationError: [u'Enter a valid date in YYYY-MM-DD format.']
The model:
class Writer(models.Model):
first = models.CharField(u'First Name', max_length=30)
other = models.CharField(u'Other Names', max_length=30, blank=True)
last = models.CharField(u'Last Name', max_length=30)
dob = models.DateField(u'Date of Birth', blank=True, null=True)
class Meta:
abstract = True
ordering = ['last']
unique_together = ("first", "last")
class Author(Writer):
language = models.CharField(max_length=20, choices=LANGUAGES, blank=True)
class Meta:
verbose_name = 'Author'
verbose_name_plural = 'Authors'
Note that the dob DateField has blank=True, null=True
The json file has structure:
[
{
"pk": 1,
"model": "books.author",
"fields": {
"dob": "",
"other": "",
"last": "Carey",
"language": "",
"first": "Peter"
}
},
{
"pk": 3,
"model": "books.author",
"fields": {
"dob": "",
"other": "",
"last": "Brown",
"language": "",
"first": "Carter"
}
}
]
The backing mysql database has the relevent date field in the relevant table set to NULL as default and Null? = YES.
Any ideas on what I'm doing wrong or how I can get loaddata to accept null date values?
===== EDIT:
Daniel's answer worked, I'm redfaced.