如何在Django中生成303 Http响应? [英] How to produce a 303 Http Response in Django?
本文介绍了如何在Django中生成303 Http响应?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你知道有什么办法实现吗?
解决方案
你可能只是覆盖HttpResponse,就像其他响应一样:
class HttpResponseSeeOther(HttpResponseRedirect):
status_code = 303
return HttpResponseSeeOther('/ other-url /')
Last couple of days we were discussing at another question the best to manage randomness in a RESTful way; today I went to play a little bit with some ideas in Django only to find that there is no easy standard way of returning a 303 response (nor a 300 one, btw), that is, there doesn't seem to exist an HttpResponseSeeOther inside django.HTTP or in another place.
Do you know any means for achieving this?
解决方案
You could just override HttpResponse, like the other Responses do:
class HttpResponseSeeOther(HttpResponseRedirect):
status_code = 303
return HttpResponseSeeOther('/other-url/')
这篇关于如何在Django中生成303 Http响应?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文