解决django.core.exceptions.ValidationError: [“‘‘ value has an invalid date format. It must be in YYYY-

Posted Jason_WangYing

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了解决django.core.exceptions.ValidationError: [“‘‘ value has an invalid date format. It must be in YYYY-相关的知识,希望对你有一定的参考价值。

django.core.exceptions.ValidationError: ["'' value has an invalid date format. It must be in YYYY-MM-DD format."]

说明下,报这个错的原因是django使用DateField()或者DateTimeField()时设置了default='',有时系统会自动填充'',由于是空字符串不符合时间类型。

解决办法:

 you have to delete all migrations and erase your database data too and do migrations again

python manage.py makemigrations


python manage.py migrate --fake

建议设置时间类型字段时:

createtime = models.DateTimeField(blank=True,null=True,default=datetime.date(1900,1,1) verbose_name='创建时间')

以上是关于解决django.core.exceptions.ValidationError: [“‘‘ value has an invalid date format. It must be in YYYY-的主要内容,如果未能解决你的问题,请参考以下文章

django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE的解决办法(转)(代码片段

解决报错:from err django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module. Did you ins

解决django.core.exceptions.ValidationError: [“‘‘ value has an invalid date format. It must be in YYYY-

Error loading MySQLdb module: No module named 'MySQLdb'. django.core.exceptions。

django报错:django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module. Did you install

django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3