报这个错的原因是因为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. Java中Lambda表达式基础及使用详解

    概述 Lambda 是JDK 8 的重要新特性.它允许把函数作为一个方法的参数(函数作为参数传递进方法中),使用 Lambda 表达式可以使代码变的更加简洁紧凑,使Java代码更加优雅. 标准格式 三 ...

  2. 为什么网络损伤仪WANsim中没有流量通过

    在使用网络损伤仪 WANsim 的过程中,有时候发现网损仪中没有流量通过.有些小伙伴可能会想:自己所有配置都是正确的 ,为什么会没有流量通过呢? 有可能,是你忽略了一些东西. 下面,我总结了一些导致网 ...

  3. NOIP 模拟 $16\; \rm God Knows$

    题解 \(by\;zj\varphi\) 对于这道题,不难想到可以用 \(dp\),就是求一个最小权极长上升子序列 设 \(dp_i\) 表示最后一个选 \(i\) 时,覆盖前 \(i\) 条边的最小 ...

  4. Git进行clone的时候,报错:remote: HTTP Basic: Access denied fatal: Authentication failed for ...

    先执行: git config --system --unset credential.helper 原因:用户名或者密码错: 会提示让重新输入用户名和密码,输入正确的用户名和密码即可! 这样以后发现 ...

  5. Java String.split()的特殊用法

    1 //用多种字符分隔字符串 2 public class Main { 3 /* 4 * "(1,2),(2,4),(3,6),(4,7)"按[(),]分隔 5 * 空白(1,2 ...

  6. JDBC中的元数据——1.数据库元数据

    package metadata; import java.sql.Connection; import java.sql.DatabaseMetaData; import javax.sql.Dat ...

  7. Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient

    1.今天在进行hive测试的时候,发现hive一直进不去,并且报了这个错误. Unable to instantiate org.apache.hadoop.hive.ql.metadata.Sess ...

  8. “类型思维”之Typescript,你掌握了吗?

    (一)背景 JavaScript是一门动态弱类型语言 对变量的类型非常宽容 而且不会在这些变量和它们的调用者之间建立结构化的契约. 试想有这么几个场景: 1: 你调用一个别人写的函数,但是这个人没有写 ...

  9. Python__requests模块的基本使用

    1 - 安装和导入 pip install requests import requests 2 - requsts的请求方法 requests.get('https://www.baidu.com/ ...

  10. VUE带Token访问Abp Vnext Api

    上篇登录保存token用了3种方式,都可以在header带上Token访问,本次使用第四种保存方式Vuex中保存状态 stroe中配置好需要保存的字段及方法 import Vue from 'vue' ...