32👍
✅
You could just override HttpResponse, like the other Responses do:
class HttpResponseSeeOther(HttpResponseRedirect):
status_code = 303
return HttpResponseSeeOther('/other-url/')
👤gak
21👍
The generic HttpResponse object lets you specify any status code you want:
response = HttpResponse(content="", status=303)
response["Location"] = "http://example.com/redirect/here/"
If you need something re-usable then Gerald’s answer is definitely valid; simply create your own HttpResponseSeeOther class. Django only provides these specific classes for a few of the most common status codes.
- [Django]-Getting Values of QuerySet in Django
- [Django]-How do I install psycopg2 for Python 3.x?
- [Django]-How do you detect a new instance of the model in Django's model.save()
Source:stackexchange.com