报这个错的原因是因为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. mybaits进阶01

    在以上mybait入门的改进(增加了接口让增删改查 后期跟容易) 注意:主配置文件和映射配置文件内容不变,但是映射文件要和对应接口放于同目录下并且名称必须相同 一.接口创建 public interf ...

  2. docker开源系统监控软件Nagios

    开源的系统监控软件 下面整理了3个: 1.Zabbix 2.Nagios 3.Open-Falcon 这位博主进行的完整的介绍: https://www.cnblogs.com/linuxandy/p ...

  3. Vue 插槽 slot的简单实用

  4. 【AE】多表的联合查询

    多表的联合查询 // Create the query definition. IQueryDef queryDef = featureWorkspace.CreateQueryDef(); // P ...

  5. mybatis根据表逆向自动化生成代码(自动生成实体类、mapper文件、mapper.xml文件)

    .personSunflowerP { background: rgba(51, 153, 0, 0.66); border-bottom: 1px solid rgba(0, 102, 0, 1); ...

  6. 接上一篇安装linux问题,解决redis安装后make test错误

    (file "tests/helpers/bg_complex_data.tcl" line 10) Killing still running Redis server 3987 ...

  7. Spring Cloud总结

    restTemplate 消费者模块编写restTemplate配置类,即可在控制层调用提供者模块 // 配置类 @Configuration public class ApplicationCont ...

  8. unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source 解决办法

    Project -> Properties -> C/C++ -> Precompiled Headers -> Precompiled Header -> 选择Not ...

  9. 并发编程之:Lock

    大家好,我是小黑,一个在互联网苟且偷生的农民工. 在之前的文章中,为了保证在并发情况下多线程共享数据的线程安全,我们会使用synchronized关键字来修饰方法或者代码块,以及在生产者消费者模式中同 ...

  10. 《手把手教你》系列技巧篇(二十三)-java+ selenium自动化测试-webdriver处理浏览器多窗口切换下卷(详细教程)

    1.简介 上一篇讲解和分享了如何获取浏览器窗口的句柄,那么今天这一篇就是讲解获取后我们要做什么,就是利用获取的句柄进行浏览器窗口的切换来分别定位不同页面中的元素进行操作. 2.为什么要切换窗口? Se ...