问题:

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.djangoprojec
t.com/en/dev/ref/databases/#mysql-sql-mode

 

解决方法:在settings.py中入DATABASES['OPTIONS']['init_command'] = "SET sql_mode='STRICT_TRANS_TABLES'":

  如下:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'wanwen',
        'USER':'root',
        'PASSWORD':'',
        'HOST':'127.0.0.1',
        'PORT': '3306',         # 数据库使用的端口
        'OPTIONS':{'init_command':'SET sql_mode="STRICT_TRANS_TABLES",storage_engine=INNODB;'}  #设置数据库为INNODB,为第三方数据库登录用
    }
}

posted on 2019-09-05 15:35  大话人生  阅读(1009)  评论(0编辑  收藏  举报