[Fixed]-Disabling Django CSRF for views that do not always have a response

7👍

Django really expects view functions to return responses. Maybe you could return an empty response instead of None? Or return an HTTP error code?

9👍

I know you already got your answer, and indeed Ned’s right;
but in addition to that: not only Django really expects views to return a response, your client also! It’s an HTTP error and likely a resource waste not to return something (and thus close the connection straight away)!

I would think that a 204 No Content or 304 Not modified (see: HTTP Status Codes) are the appropriate http codes to use in this situation; in django:

return HttpResponse(status=204)

or

from django.http import HttpResponseNotModified
return HttpResponseNotModified()

Leave a comment