Mar*_*agh 74

这两者有所不同:

HttpResponseRedirect第一个参数的情况下只能是一个url.

redirect这将最终回到一个HttpResponseRedirect可以接受model,viewurl因为它是"对"的说法.因此,它可以"重定向"到它的灵活性.

我也喜欢如何redirect更短.所以我用完redirectHttpResponseRedirect.

两者都可以使用.


Sri*_*aju 7

从文档 -

redirect(to[, permanent=False], *args, **kwargs)返回 HttpResponseRedirect传递的参数的相应URL.

从定义来看也一样.那是什么捷径.两者都是一样的.

快捷方式通常写在实际API之上一级.所以redirect封装HttpResponseRedirectHttpResponsePermanentRedirectarg permanent=False.

使用HttpResponseRedirect结束没有重大缺点redirect.希望这清除它.