?: (mysql.W002) MySQL Strict Mode is not set for database connection 'default'
阿新 • • 發佈:2019-02-13
問題
django專案中,執行python manage migrate
時
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/1.10/ref/databases/#mysql-sql-mode
解決
在settings中,在DATABASES變數定義處下面新增
DATABASES['OPTIONS']['init_command'] = "SET sql_mode='STRICT_TRANS_TABLES'"
或者在DATABASES變數定義時,新增上面命令中所示的鍵值對。