HttpResponse vs. Render

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.


render is used to for what the name already indicates: to render a template file (mostly HTML, but could be any format). render is basically a simple wrapper around a HttpResponse which renders a template, though as said in the previous answer, you can use HttpResponse to return other things as well in the response, not just rendering templates.

Tags:

Http

Django