HttpResponse vs. Render

后端 未结 3 1049
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-05 15:22

I was looking over some code and came to this question -- Django: What is the difference b/w HttpResponse vs HttpResponseRedirect vs render_to_response -- which discusses the di

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-05 15:33

    Sure, say you're making an AJAX call and want to return a JSON object:

    return HttpResponse(jsonObj, mimetype='application/json')
    

    The accepted answer in the original question alluded to this method.

提交回复
热议问题