|
|
|
|
|
by pindi
4805 days ago
|
|
> Django does not have a built in JSON HTTP response, so you are going to have to either man up and roll your own (good luck) Am I missing something? What's wrong with: return HttpResponse(json.dumps(data), mimetype='application/json')
Wrap it up in a convenience function and you're done.The JSONResponse class suggested automatically implements JSONP, which is extremely dangerous. Consider a view on /accounts/info which returns some information about the currently logged in user. A malicious site could embed <script src="http://example.com/accounts/info?callback=someFunction">
and access the account information of any user logged into your site. JSONP is a technique to bypass the same-origin policy in appropriate cases; don't just blindly apply it everywhere or you're giving up the protection of the policy. |
|