django-models - 当我以原始 json 格式从邮递员发送数据时......名称将不会接收数据......为什么
问题描述
这是我的代码....views.py 如果我使用来自邮递员的表单数据发送数据,它将接收数据。但是原始 json 数据不起作用为什么
from django.http import HttpResponse, JsonResponse
from django.shortcuts import render
# Create your views here.
from django.views.decorators.csrf import csrf_exempt
@csrf_exempt
def create_book(request):
if request.method == "POST":
name = request.POST.get('author_name')
return JsonResponse({
"name": name
})
else:
return JsonResponse({"name": "notfound"})
…………………………………………………………………………
解决方案
推荐阅读
- webpack - webpack - 导入 mdi 字体图标不起作用,但其他 scss 文件可以
- python-3.x - 模型对象的 Python 3 数据类类型提示
- python - 将字典文件读取为 pyspark 数据框
- node.js - 如何使用 MERN 堆栈仅发送要更新的字段?
- azure - Azure Devops 发布管道 XML 变量替换不起作用
- python - Python 命令行单线器使用 xmltodict 将 xml 转换为 json
- javascript - 无法读取未定义节点 js multer 的属性“路径”
- python - Python - 在迭代另一个字典时向字典添加新条目
- sql - TSQL - 基于部分唯一性的联合记录
- python - 动态选择(那些为输入的新值而更新的选择。)