Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Add support to use a custom reason-phrase in response's status line #1032

wants to merge 2 commits into from

3 participants


HTTP protocol uses the reason-phrase in the response's status line as a message meant solely for human consumption so is perfectly valid to change that phrase for whatever the api designer needs.
django.http.HttpResponse class should allow users to change the reason-phrase if they need so, for example, through a status_text attribute.


You could have done:
getattr(response, 'status_text', status_text)
so the default would go directly to status_text

Yeap, I totally missed that one!


The API should be consistent with the API to set the status code. This also needs tests and docs.

@aaugustin aaugustin closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  django/core/handlers/
2  django/core/handlers/
@@ -257,7 +257,7 @@ def __call__(self, environ, start_response):
status_text = STATUS_CODE_TEXT[response.status_code]
except KeyError:
status_text = 'UNKNOWN STATUS CODE'
- status = '%s %s' % (response.status_code, status_text)
+ status = '%s %s' % (response.status_code, getattr(response, 'status_text', status_text))
response_headers = [(str(k), str(v)) for k, v in response.items()]
for c in response.cookies.values():
response_headers.append((str('Set-Cookie'), str(c.output(header=''))))
Something went wrong with that request. Please try again.