Python Django,Json序列化,返回Json数据,JsonResponse

应用名/views.py(视图,视图函数,返回Json数据,JsonResponse):

from django.shortcuts import render
from django.http import JsonResponse


# 视图函数,返回Json数据。
def ajax_handle(request):
    '''ajax请求处理'''
    # 返回的json数据 {'res':1}
    return JsonResponse({'res':1})  # 通过JsonResponse对象返回Json数据。

猜你喜欢

转载自blog.csdn.net/houyanhua1/article/details/84968441