django

How can I return HTTP status code 204 from a Django view?


I want to return status code 204 No Content from a Django view. It is in response to an automatic POST which updates a database and I just need to indicate the update was successful (without redirecting the client).

There are subclasses of HttpResponse to handle most other codes but not 204.

What is the simplest way to do this?


Solution

  • return HttpResponse(status=204)