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?
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?
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.