Instead of doing this:
res = HttpResponse("Unauthorized") res.status_code = 401 return res
Is there a way to do it without typing it every time?
class HttpResponseUnauthorized(HttpResponse): def __init__(self): self.status_code = 401 ... return HttpResponseUnauthorized()