我正在尝试使用导入 csv 文件,django-import-export
但遇到了这个无意义的错误:
Line number: 44 - Column 'completion_date': Enter a valid date.
OrderedDict([(u'id', u''), ('language', 1868), ('type', 10), (u'language_code', u'fr'), ('completion_date', datetime.date(2015, 12, 31)), (u'document_slug', u'obs'), (u'is_online', u'1'), (u'completion_rate', u'50'), (u'is_done', u'0'), (u'completion_date_string', u'2015-12-31'), (u'in_door43', u'1'), (u'in_uw', u'1')])
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/import_export/resources.py", line 374, in import_data
self.import_obj(instance, row, real_dry_run)
File "/usr/local/lib/python2.7/dist-packages/import_export/resources.py", line 238, in import_obj
self.import_field(field, obj, data)
ValueError: Column 'completion_date': Enter a valid date.
这是我的类,定义completion_date
为DateField
:
python_2_unicode_compatible
class Progress(models.Model):
language = models.ForeignKey('td.Language', limit_choices_to={'gateway_flag': True})
type = models.ForeignKey('Document')
is_online = models.NullBooleanField()
method = models.CharField(max_length=200, choices=METHODS, blank=True)
completion_rate = models.PositiveSmallIntegerField(choices=COMPLETION_RATE, null=True, blank=True)
completion_date = models.DateField(null=True, blank=True)
qa_level = models.PositiveSmallIntegerField(choices=QA_LEVEL, null=True, blank=True)
in_door43 = models.NullBooleanField()
in_uw = models.NullBooleanField()
partners = models.ManyToManyField('Partner', blank=True)
notes = models.TextField(blank=True)
is_done = models.BooleanField(default="false")
def __str__(self):
return str(self.type)
class Meta:
unique_together = ("language", "type")
为什么datetime.date()
不是有效日期?