报这个错的原因是因为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. 通过白码SQL数据库对接功能改进原系统

    前言: 之前提到过之所以要使用数据库对接功能,就是因为原有系统上有些功能存在不完善甚至不好用的情况,需要二次开发来优化业务流程或是直接用白码用户端上的通用功能.对接了之后就不需要再写代码来搭建或者优化 ...

  2. 将JDK默认编码设置为UTF-8

    此博文非原创:参考小兵qwer   https://blog.csdn.net/xiaobing_122613/article/details/70209716 只是想留下对自己有用的东西,同时帮助更 ...

  3. noip 模拟9 题解

    rp++==文化课报废 考试经过 先看T1,有被1e12吓到,但根据经验这很可能是水题,经过一番观察后直接打表,似乎看出了规律,觉得应该有了正解,写完之后顺利过掉大样例,但似乎时间稍慢一点,写上快读交 ...

  4. pip的问题 Can't connect to HTTPS URL because the SSL module is not available

    pip is configured with locations that require TLS/SSL, however the ssl module in Python is not avail ...

  5. SpringBoot监听redis订阅监听和发布订阅

    前言 我们可以在redis中发布一条订阅到通道中,所有监听了这个通道的都可以收到这个发布的内容! redis订阅监听配置类 代码如下: RedisListenerConfig.java package ...

  6. css - 响应式

    css - 响应式 移动设备尺寸 移动设备的尺寸各不相同,大体上可以做如下划分: 768px以下的是手机屏幕 768px-991px是平板ipad屏幕 992px-1199是大平板屏幕 1200极其以 ...

  7. Maven脑图

    转自:https://segmentfault.com/a/1190000017832792 参考:https://www.cnblogs.com/mzywucai/p/11053341.html

  8. JAVA虚拟机中的堆内存Heap与栈内存Stack

    原文链接:http://www.cnblogs.com/laoyangHJ/archive/2011/08/17/gc-Stack.html 深入Java虚拟机:JVM中的Stack和Heap 在JV ...

  9. NIO中的File

    package nio; import java.io.IOException; import java.nio.charset.Charset; import java.nio.file.Files ...

  10. 神舟G7-CT7NK 安装tensorflow-gpu

    参考https://www.cnblogs.com/xbit/p/9768238.html 直接安装,运行keras mnist数字识别报错: Could not create cudnn handl ...