djangosnippets.org: Latest snippets posted by anilshanbhaghttps://djangosnippets.org/users/anilshanbhag/2012-12-23T11:05:05.312451-06:00anilshanbhagJSON decorator for views handling ajax requests
2012-12-23T11:05:05.312451-06:00anilshanbhaghttps://djangosnippets.org/snippets/2869/<p>Sample usage for using decorator
<code>@json_response(ajax_required=True, login_required=True)</code>
<code>def subscribe(request):</code>
<code>return {"status":"success"}</code></p>
<p>Converts a function returning dict into json response. Does is_ajax check and user authenticated check if set in flags. When function returns HttpResponse does nothing.</p>
Freely redistributable