python - This django.core.exceptions.ValidationError occurs when running django
淡淡烟草味
淡淡烟草味 2017-05-18 11:00:06
0
2
1032

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?

淡淡烟草味
淡淡烟草味

reply all (2)
伊谢尔伦

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

    刘奇

    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?

      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!