Skip to main content
 首页 » 编程设计

python之如何使用 Django 发送/获取 JSON 对象

2025年05月04日24lvdongjie

我知道如何使用 JQuery ajax 功能调用 Django 的“url View ”。

import simplejson as json 
def the_view(request): 
    fruits = {'color':5, 'type': 22} 
    jfruit = json.dump(fruits) 
 
return render_to_response( THE JSON OBJECT!!! ...how? ) 

请您参考如下方法:

返回 HttpResponse(simplejson.dumps(mydictionary), mimetype="application/json")

参见 b-list