1.搭建Django2.0+Python3+MySQL5时同步数据库时报错:
raise ImproperlyConfigured(‘mysqlclient 1.3.13 or newer is required; you have %s.’ % Database.version)
django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.
解决办法:
找到Python安装路劲下的python\Lib\site-packages\django\db\backends\mysql\base.py文件
将文件中的如下代码注释
2.针对Error: You must either define the environment variable DJANGO_SETTINGS_MODULE …问题的解决
使用intelliJ Idea开发django项目,启动 manage.py 测试时,会出现如上所示问题。
根据提示,有两种解决方法:
a.
define the environment variable DJANGO_SETTINGS_MODULE
在manage.py文件中添加
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "你的project.settings")
call settings.configure() before accessing settings
manage.py文件中添加
from django.conf import settings
settings.configure(DEBUG=True)
b.
3.pycharm 安装PIL 失败
!
4.python3报错:AttributeError:strobjecthasnoattributedecode
错误代码:query = query.encode(errors=‘replace’)
解决方法:把decode改为encode即可
5.django报错 ‘WSGIRequest’ object has no attribute ‘session’
‘WSGIRequest’ object has no attribute xxxx错误
经测试和比对,是settings.py里MIDDLEWARE导致的问题
MIDDLEWARE参数在低一点的django版本里应该写成MIDDLEWARE_CLASSES
后可能django升级后改成了MIDDLEWARE,版本大概在1.8—1.10之前