How can I return HTTP status code 204 from a Django view?
When using render, there is a status
keyword argument.
return render(request, 'template.html', status=204)
(Note that in the case of status 204 there shouldn't be a response body, but this method is useful for other status codes.)
return HttpResponse(status=204)