
python-Django
记录一个前端开发搭建一个博客的心酸史
木子聊前端
一起探究前端的那些坑坑,用故事讲写代码
展开
-
ord(readfn(1)) TypeError: ord() expected a character, but string of length 0 found --记录
背景从git clone 下来一个 Django 1.1项目,而本地安装是 Django 3.3 而且 使用了whoosh 出现如下问题: File "/usr/local/lib/python3.7/site-packages/whoosh/index.py", line 626, in check_size sz = stream.read_varint() File "/usr/local/lib/python3.7/site-packages/whoosh/filedb/struct原创 2020-08-10 10:58:38 · 7340 阅读 · 0 评论 -
ImportError: cannot import name ‘six‘ from ‘django.utils‘ -问题记录
背景在运行django3.0 的时候报错,代码中包含了django1.11的代码出现如下错误:ImportError: cannot import name 'six' from 'django.utils'原因django 3.x 系列删除了six. 版本升级问题解决安装 sixpip3 install six进入安装包目录cd /usr/local/lib/python3.7/site-packages将six.py拷贝进django/utils/目录下cp six.py原创 2020-08-07 17:27:11 · 6830 阅读 · 0 评论 -
django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 -问题记录
背景在使用django3.0 +pymysql 驱动的时候报错django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.2原因django3.0 新版本不想在支持pymysql 驱动大力推行 mysqlclient 作为驱动。但是我在mysqlclient是总是失败,没办法还是安装pymysql ,但是有有问题,只能参照网上的方法修改源码,很纠结;解决方法原创 2020-08-07 17:09:22 · 247 阅读 · 0 评论 -
TypeError: __init__() missing 1 required positional argument: ‘on_delete‘ 没有留意的问题
背景Django3.0 中创建Model时报以下错误TypeError: init() missing 1 required positional argument: ‘on_delete’原因django 升级到2.0之后,表与表之间关联的时候,必须要写on_delete参数,否则会报异常解决办法找到有外键关联的地方 ForeignKey 加入on_delete:如原来的:models.ForeignKey(Contract)修改为models.ForeignKey(Contra原创 2020-08-07 16:41:58 · 402 阅读 · 0 评论 -
Specifying a namespace in include() without providing an app_name is not supported 记录
背景运行 Django3.0 的时候 报错,具体表现如下:Specifying a namespace in include() without providing an app_name is not supported. Set the app_name attribute in the included module,or pass a 2-tuple containing the list of patterns and app_name instead.原因依据包错文件 conf.原创 2020-08-07 16:30:04 · 573 阅读 · 0 评论 -
ImportError: cannot import name ‘render_to_response‘ 解决方法
背景在开发 Django 项目,的时候 原来的版本是1.xx版本,现在直接用 diango3.0 出现的问题:在直接运行爆出错误:ImportError: cannot import name 'render_to_response' from 'django.shortcuts'原因Django 3.0 已经将 render_to_response 移除了,但是项目中还在使用解决办法用render 代替 render_to_response用途:都是渲染模版用的不同点:render 方原创 2020-08-07 16:11:21 · 6467 阅读 · 0 评论 -
‘staticfiles‘ is not a registered tag library --django3.0
背景在运行 升级 django1.11 到 django3.0 到时候遇到如下场景问题:django.template.exceptions.TemplateSyntaxError: 'staticfiles' is not a registered tag library. Must be one of:admin_listadmin_modifyadmin_urlsblog_tagscachecomment_tagshighlighthumanizei18nl10nlogmo原创 2020-08-07 15:46:48 · 683 阅读 · 0 评论