报这个错的原因是因为json.dumps函数发现字典里面有bytes类型的数据,无法编码。解决方法:将bytes类型的数据就把它转化成str类型。

定义dates[]后return JsonResponse({'status': 200,'message':'success','data':datas})报上述错误

解决方法:return JsonResponse({'status': 200,'message':'success','data':str(datas)})

报错:CSRF token missing or incorrect.

解决方法:在view文件中加入装饰器@csrf_exemp

代码如下:

from django.views.decorators.csrf import csrf_exempt

@csrf_exempt
def contact(request):
django之所以引进CSRF是为了避免Cross Site Request Forgeries攻击,而上面的解决方法恰好禁止掉这个django的功能。

Object of type type is not JSON serializable的更多相关文章

  1. celery 4.1下报kombu.exceptions.EncodeError: Object of type 'bytes' is not JSON serializable 处理方式

    #python代码如下 from celery import Celeryimport subprocess app = Celery('tasks', broker='redis://localho ...

  2. Object of type 'ListSerializer' is not JSON serializable “listserializer”类型的对象不可JSON序列化

    Object of type 'ListSerializer' is not JSON serializable “listserializer”类型的对象不可JSON序列化 一般原因为 序列化的对象 ...

  3. TypeError: Object of type 'int64' is not JSON serializable

    错误类型:TypeError: Object of type 'int64' is not JSON serializable 错误场景:对Numpy和Pandas结果进行json.dumps报错 错 ...

  4. TypeError: Object of type 'int32' is not JSON serializable ——已解决

    将模型用flask封装,返回json时报错:TypeError: Object of type 'int32' is not JSON serializable 网上搜索出的解决方案:重写json.J ...

  5. labelme2coco问题:TypeError: Object of type 'int64' is not JSON serializable

    最近在做MaskRCNN 在自己的数据(labelme)转为COCOjson格式遇到问题:TypeError: Object of type 'int64' is not JSON serializa ...

  6. Object of type 'ndarray' is not JSON serializable

    Object of type 'ndarray' is not JSON serializable import numpy as np import json arr=np.asarray([345 ...

  7. TypeError: Object of type 'int32' is not JSON serializable

    将模型用flask封装,返回json时报错:TypeError: Object of type 'int32' is not JSON serializable 网上搜索出的解决方案:重写json.J ...

  8. TypeError: Object of type 'ListSerializer' is not JSON serializable

    问题: 解决:ser.data是json数据,你想要的

  9. Object of type Decimal is not JSON serializable

    json遇到Decimal 型数据无法正确处理 解决方案 import json result = [ {'name': '小红', 'age': 26, 'balance': decimal.Dec ...

  10. typeerror object of type ‘decimal‘ is not json serializable jsonify

    当使用flask的jsonify返回json数据时,由于数据库有些字段类型使用decimal,而jsonify无法处理 解决方案 导入下面的包即可解决 pip install simplejson

随机推荐

  1. 转载自-阮一峰-测试框架 Mocha 实例教程

    测试框架 Mocha 实例教程   作者: 阮一峰 日期: 2015年12月 3日 Mocha(发音"摩卡")诞生于2011年,是现在最流行的JavaScript测试框架之一,在浏 ...

  2. 【spring 注解驱动开发】spring ioc 原理

    尚学堂spring 注解驱动开发学习笔记之 - Spring容器创建 Spring容器创建 1.Spring容器创建-BeanFactory预准备 2.Spring容器创建-执行BeanFactory ...

  3. numpy、pandas、scipy、matplotlib、jieba、 openpyxl、pillow的安装

    cmd环境下进入python安装包里的Script文件夹 安装numpy 安装pandas 安装scipy 安装matplotlib 安装jieba(应该是之前装的库安装依赖时下载了) 安装openp ...

  4. PipedInputStream and PipedOutputStream example

    必须要有PipedInputStream ,PipedOutputStream 在不同线程,不然死锁 Java.io.PipedOutputStream and java.io.PipedInputS ...

  5. python实现两台不同主机之间进行通信(客户端和服务端)——Socket

    大家好,我是辰哥~ 今天教大家通过Python进行Socket网络编程 (做一个聊天程序) 可以实现在不同的主机(电脑)之间进行通话. 具体效果如何,接着往下看 可以看到客户端(上方)向服务器端(下方 ...

  6. JAVA《多线程多人上线通知案例》

    package com.wangbiao.palyermanager; import com.wangbiao.player.Player; /** * TODO * * @author wangbi ...

  7. MySQL主库手动复制至从库

    原文转自:https://www.cnblogs.com/itzgr/p/10233932.html作者:木二 目录 一 主库手动复制至从库 1.1 Master主库锁表 1.2 主库备份 1.3 从 ...

  8. Adaptive AUTOSAR 学习笔记 16 - 时间同步和网络管理

    本系列学习笔记基于 AUTOSAR Adaptive Platform 官方文档 R20-11 版本 AUTOSAR_EXP_PlatformDesign.pdf.作者:Zijian/TENG 原文地 ...

  9. Python命名空间——locals()函数和globals()函数及局部赋值规则

    Python使用叫做命名空间的东西来记录变量的轨迹.命名空间只是一个 字典,它的键字就是变量名,字典的值就是那些变量的值.实际上,命名空间可以象Python的字典一样进行访问,一会我们就会看到. 在一 ...

  10. (九)羽夏看C语言——C++番外篇

    写在前面   此系列是本人一个字一个字码出来的,包括示例和实验截图.本人非计算机专业,可能对本教程涉及的事物没有了解的足够深入,如有错误,欢迎批评指正. 如有好的建议,欢迎反馈.码字不易,如果本篇文章 ...