美文网首页软件测试
【填坑】python3 manage.py migrate:?:

【填坑】python3 manage.py migrate:?:

作者: 亭子青年 | 来源:发表于2017-09-02 17:41 被阅读97次

学习就是不断的踩坑,填坑

直入主题
本机环境:win8 py3.5.1 Django2.0

Django 连接mysql数据库

cmd中使用python3 manage.py migrate命令,报warn

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': 'django_test',
        'USER':'root',
        'PASSWORD':'',
        'HOST':'localhost',
        'PORT':'3306',
        #下面是新加入的
        'OPTIONS':{
            'init_command':"SET sql_mode='STRICT_TRANS_TABLES'",
            'charset':'utf8mb4',
        },
    }
}

相关文章

网友评论

    本文标题:【填坑】python3 manage.py migrate:?:

    本文链接:https://www.haomeiwen.com/subject/eqerjxtx.html