MySQL's Strict Mode fixes many data integrity problems in MySQL

?: (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. 

根据官方文档:https://docs.djangoproject.com/en/1.10/ref/databases/#mysql-sql-mode

添加

'init_command': 'SET sql_mode=STRICT_TRANS_TABLES',
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'OPTIONS': {
            'read_default_file': os.path.dirname(os.path.abspath(__file__))+'/my.cnf',
            'init_command': 'SET sql_mode=STRICT_TRANS_TABLES',
        },
    }
}

猜你喜欢

转载自blog.csdn.net/bwlab/article/details/55106787