windows 下的Python虚拟环境(vitrualen)pycharm创建Django项目

问题:MySQL Strict Mode is not set for database connection 'default'

初学Django遇到问题-MySQL Strict Mode is not set for database connection 'default',详情如下:

解决方案:添加 OPTIONS 选项,具体内容如下:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'mysite',
        'HOST': '127.0.0.1',
        'USER': 'root',
        'PASSWORD': '123456',
        'PORT': '3306',
        'OPTIONS': {
            'init_command': 'SET sql_mode="STRICT_TRANS_TABLES"',
            'charset': 'utf8mb4'
        }
    }
}

Django2.1 执行python manage.py migrate失败

版本:CentOS6.8 Django2.1

执行python manage.py makemigrations时正常,但在执行数据迁移python manage.py migrate时,报如下错误!

django.db.migrations.exceptions.MigrationSchemaMissing: Unable to create the django_migrations table ((1064, “You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘(6) NOT NULL)’ at line 1”))

经过再三检查,代码没有问题,后来才想起来是不明Django的版本问题,因为之前安装一个软件包,自动升级了Django的版本,由1.8.3升级到2.1,后来网上查了资料,真的是Django的版本问题,查了官方文档,Django2.1只支持mysql5.6以上的版本!
MYSQL下载地址:https://dev.mysql.com/downloads/windows/installer/5.6.html

原文地址:https://blog.csdn.net/joe8910/article/details/82315930

解决:PyCharm中import自定义模块无法识别的问题

两步:

  1. 打开File > Default Settings > Python Console,把选项(Add source roots to PYTHONPAT)点击勾选上

 右键点击自己的工作空间文件夹,找到Mark Directory as 选择Source Root,问题解决!

 end;

原文地址:https://www.cnblogs.com/jiangxiaobo/p/11537841.html