Home  >  Q&A  >  body text

python - This django.core.exceptions.ValidationError occurs when running django

Hello everyone!

When I was editing django's model.py, I accidentally copied a field type incorrectly:

 rdc_mysql = models.DateField(verbose_name='数据库版本',max_length=50,blank=True,null=True,default='Mysql5.6')

Later, when I logged in to the web page, I found that it was like this.

Since the format is wrong, I returned to model.py and manually changed the Datefield to charfield, as follows:

 rdc_mysql = models.CharField(verbose_name='数据库版本',max_length=50,default='Mysql5.6')

Save and exit, but when executing python manage.py migrate, an error is reported:

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

What else do I need to do?

淡淡烟草味淡淡烟草味2680 days ago1041

reply all(2)I'll reply

  • 伊谢尔伦

    伊谢尔伦2017-05-18 11:02:06

    The error message says that the fields in default must be in the format of "YYYY-MM-DD".

    reply
    0
  • 怪我咯

    怪我咯2017-05-18 11:02:06

    I took a look in the database. Although my model.py has changed, the things in the database have not changed. In other words, python manager.py makemigrations has not changed the table structure in mysql. Is it now only possible through mysql? Can it be changed inside, but cannot be changed through Django statements?

    reply
    0
  • Cancelreply