本文提供解决方法,解释原因在参考的文章中有具体解释
django下载
首先推荐使用:pip版本号 install django -i 镜像源的方式下载,如:
pip3.8 install django -i https://pypi.tuna.tsinghua.edu.cn/simple/
(清华镜像源),这样可以避免存在多个Python版本而导致的所使用的Python版本与django版本匹配问题,当然下载时好像还要下载一些依赖库,下载时看报错提示操作即可
setting文件修改
在pycharm中创建django项目时,在setting文件中需要import os
使用MySQL数据库时,同样需要到setting文件中修改配置将sqlite改为mysql,参考修改如下:
数据库连接报错Server returns invalid timezone. Need to set ‘serverTimezone‘ property
在pycharm中连接mysql数据库时,在文件名字后加上?serverTimezone=GMT
具体原因参考文章:MySQL报错Server returns invalid timezone. Need to set ‘serverTimezone‘ property.
数据库迁移报错Error loading MySQLdb module.Did you install mysqlclient?
数据库迁移时,运行python manage.py makemigrations时报错,首先检查是否下载mysqlclient模块,可以在pycharm中的file中查看各项目环境中的各Python解释器,其中会显示下载的第三方库
确保已经存在该库后,找到pycharm右上角的搜索,输入base,点击第一个
将该文件的第239行注释
具体原因参考文章:django报错: raise NotSupportedError(django.db.utils.NotSupportedError: MySQL 8 or later is required
如果仍然报错,尝试:
大一在读,不足请指正