Custom status reason phrasesΒΆ

According to the HTTP specification, the reason phrase for an HTTP response status may be customised, so you could return 200 Alright then or 403 Get out. However, Django doesn’t support this, so twod.wsgi provides a subclass of HttpResponse which does allow custom response reasons, since they could be returned by embedded WSGI applications.

If you want to use it in your Django views, just use it like a regular Django response, but include the phrase in the status argument:

from twod.wsgi import TwodResponse

response = TwodResponse("You cannot be here", mimetype="text/plain", status="403 Get out")

For this to work, you’d need to use the enhanced Django handler.