Reputation: 828
I want to return status code different from 100 <= self.status_code <= 599
, as written in Django's HttpResponseBase class. Is there are any easy way to bypass this restriction?
Upvotes: 5
Views: 8832
Reputation: 477533
You can, if you really want, patch the .status_code
attribute. For example with:
from django.http import HttpResponse
def some_view(request):
response = HttpResponse('some data')
response.status_code = 754 # sample status code
return response
But it does not make much sense to specify a HTTP status code [wiki] outside the 100-599 range, since these are subdivided into subranges that specify in what case to return what status code.
Upvotes: 9