python manage.py migrate 报错: (mysql.W002) MySQL Strict Mode is not set for database connection 'd...

  • 解决办法:
    settings.py文件中,为DATABASES选项添加OPTIONS属性:['init_command'] = "SET sql_mode='STRICT_TRANS_TABLES'"
  • 具体位置如下所示:
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'dbname',
        'USER': 'username',
        'PASSWORD': 'password',
        'HOST': '127.0.0.1',
        'PORT': '3306',
        'OPTIONS':{
            'init_command':"SET sql_mode='STRICT_TRANS_TABLES'",
            'charset':'utf8mb4',
        },
    }
}

你可能感兴趣的:(python manage.py migrate 报错: (mysql.W002) MySQL Strict Mode is not set for database connection 'd...)