调试django的mysql严格模式

时间:2019-03-20 20:50:19

标签: mysql django

当我在MySQL上运行Django的migrate命令时,收到警告:

$ ./manage.py migrate
System check identified some issues:

WARNINGS:
?: (mysql.W002) MySQL Strict Mode is not set for database connection 'default'
    HINT: MySQL's Strict Mode fixes many data integrity problems in MySQL, such as data truncation upon insertion, by escalating warnings into errors. It is strongly recommended you activate it. See: https://docs.djangoproject.com/en/2.1/ref/databases/#mysql-sql-mode

当我查看该URL时,他们建议在'init_command'中添加DATABASE['OPTIONS'](也称为herehere)。所以我做到了:

DATABASES['default']['OPTIONS'] = {
    # Set MySQL strict mode.
    'init_command': "SET sql_mode='STRICT_TRANS_TABLES'",
}

但是警告并没有消失。

关于如何进一步调试的任何建议?

0 个答案:

没有答案