![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
Bressanone6
这个作者很懒,什么都没留下…
展开
-
Django自定义上下文处理器(context_processor)动态读取共用部分数据
上下文处理器(context_processor)定义一次,能实现共用数据的在项目里的每个页面上重复使用。比如:最新文章1、在APP目录中创建自定义的上下文处理器文件。如:app_context_processor.py2、在创建的文件中定义函数示例代码。如下from .models import Article#共用部分数据自定议上下文def myapp_context_pr...原创 2020-02-07 16:55:49 · 412 阅读 · 0 评论 -
CentOS7 下安装python3.7和pip3 并保留系统自带python2.7
1. 安装依赖环境# yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel 2. 下载Python3.7的安装包# w...转载 2018-12-12 08:58:46 · 381 阅读 · 0 评论 -
POST提交解决Forbidden (CSRF token missing or incorrect.) 问题
一、获取 Request Header里的COOKIE值 放在请求头里发送,FORM表单里可以不用设置{% csrf_token %}function getCookie(name) { var cookieValue = null; if (document.cookie && document.cookie !== '') { ...转载 2019-03-20 11:11:41 · 5787 阅读 · 0 评论 -
TypeError:Object of type 'datetime' is not JSON serializable 和 json.dumps函数输出中文乱码解决方案
1、将datetime数据格式转换成json序列化报错:Object of type 'datetime' is not JSON serializable ,重写json构造类如下:import json, datetimeclass DatetimeEncode(json.JSONEncoder): def default(self, obj):...转载 2019-03-28 23:05:05 · 485 阅读 · 0 评论 -
python中model_to_dict转QuerySert字典时,丢失DateTime 解决方案
python中用 django.forms.models import model_to_dict 转换QuerySert为字典时丢失日期数据,是因为 DateTime 字段有auto_now_add=True和auto_now=True属性的会默认添加editable=False隐藏属性。 可通过添加日期键值数据获取。如下:django.forms.models import mo...转载 2019-07-07 15:03:08 · 1332 阅读 · 0 评论