随笔分类 - Django
1
django如何将sqllite数据库改成mysql
摘要:一,安装MySQL的驱动 1,python2版本的安装MySQLdb,pip安装pip安装MySQLdb 2,python3版本的安装pySQLdb,pip安装pip install pySQLdb二,修改配置 打开setting.py配置文件DATABASES = { # 'default': {
阅读全文
mysqlclient 1.4.0 or newer is required; you have %s.' % Database.__version__
摘要:在setting.py的__init__.py里 import pymysql pymysql.version_info = (1, 4, 13, "final", 0) pymysql.install_as_MySQLdb() # 使用pymysql代替mysqldb连接数据库
阅读全文
pip install pymysql报错connet time out
摘要:1.pip install pymysql报错 pip install pymysql WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection b
阅读全文
django.core.exceptions.ImproperlyConfigured: mysqlclient 1.4.0 or newer is required; you have 0.10.0.
摘要:报错信息 django.core.exceptions.ImproperlyConfigured: mysqlclient 1.4.0 or newer is required; you have 0.10.0. 原因 原因是 MySQLclient 目前只支持到 Python3.4,你使用了更高版
阅读全文
Django2.1集成xadmin管理后台所遇到的错误集锦,解决填坑
摘要:django默认是有一个admin的后台管理模块,但是丑,功能也不齐全,但是大神给我们已经集成好了xadmin后台,我们拿来用即可,但是呢,django已经升级到2.1版本了,xadmin貌似跟不上节奏,那么在集成过程中咱就一步一步填坑吧,这也是一种学习的过程,遇到错误,找到错误的地方,看看djan
阅读全文
from django.contrib.auth import login
摘要:错误提示: File "D:\code\python_work\learning_log\users\urls.py", line 4, in <module> from django.contrib.auth.views import loginImportError: cannot import
阅读全文
xadmin报错TypeError: __init__() takes 1 positional argument but 6 were given
摘要:报错信息: \xadmin\views\dashboard.py", line 285, in init *args, **kwargs) TypeError: init() takes 1 positional argument but 6 were given 修改:forms.Field.in
阅读全文
render() got an unexpected keyword argument 'renderer'
摘要:当我们使用Django开发个人网站时,如果用到Ueditor,有时会遇到这个问题。 解决方法如下。 我们启动项目,进入文章发布页面。提示出错: render() got an unexpected keyword argument 'renderer' 错误页面上有提示,出错的地方是下面文件的93行
阅读全文
'bool' object is not callable
摘要:使用 Django自带的 auth 用户验证功能,编写函数,使用 is_authenticated 检查用户是否登录,结果报错: TypeError at / 'bool' object is not callable 编写函数如下: 查询相关资料,发现 is_authenticated 是属性而不
阅读全文
UnicodeDecodeError: 'gbk' codec can't decode byte 0xa6 in position 9737: illegal multibyte sequence
摘要:Django2.2 安装后,使用runserver进行开发,出错时错误信息只显示于控制台命令行,而在前端页面只显示一行 “A server error occurred. Please contact the administrator.” 排错很不方便,仔细查看控制台的错误信息,提示 Unicod
阅读全文
django.contrib.auth.middleware.AuthenticationMiddleware' must be in MIDDLEWARE in order to use the admin application.
摘要:错误日志 ERRORS: ?: (admin.E408) 'django.contrib.auth.middleware.AuthenticationMiddleware' must be in MIDDLEWARE in order to use the admin application. ?:
阅读全文
ForeignKey(unique=True) is usually better served by a OneToOneField.
摘要:primary_key表示unique = True.所以,正如警告所说,你可能应该使用OneToOneField
阅读全文
NameError: name 'reload' is not defined
摘要:对于 Python 2.X:import sysreload(sys)sys.setdefaultencoding("utf-8") 对于 <= Python 3.3:import impimp.reload(sys) 注意: 1. Python 3 与 Python 2 有很大的区别,其中Pyth
阅读全文
No module named 'django.core.urlresolvers'
摘要:换成django.urls
阅读全文
No module named 'ckeditor'
摘要:使用pip install django-ckeditor安装
阅读全文
项目运行报错query = query.encode('utf-8').decode(errors='replace')
摘要:打开D:\ProgramData\Anaconda3\Lib\site-packages\django\db\backends\mysql\operations.py文件 def last_executed_query(self, cursor, sql, params): # With MySQL
阅读全文
django static里面的文件访问不了
摘要:在settings.py里面编辑 添加 STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'static'), ) 另外把 STATIC_ROOT = os.path.join(BASE_DIR, 'static') 改为 STATIC_ROOT = os.pa
阅读全文
AttributeError: 'str' object has no attribute 'decode'
摘要:python3下列代码会报上边的错 print("Response:", resp.text.decode('unicode_escape'))解决办法:print("Response:", resp.text.encode('utf-8').decode('unicode_escape'))中间加
阅读全文
python import pymysql报错
摘要:可能出现的错误点 1、mac终端或者cmd,执行命令pip list,看pymysql是否存在 2、pycharm-file-setting/other setting-project interpreter,查看是否有mysql,如果没有,可以自行添加 3.安装多个版本python解释器 本人终端
阅读全文
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module. Did you install mysqlclient?
摘要:问题原因及解决方法 python3 中django连接mysql使用的包是pymysql, 所以第一步先安装 pymysql pip install pymysql, 安装了并不代表就可以了, 还需要在项目的__init__.py myblog/ ├── apps ├── Dockerfile ├─
阅读全文
1