当我调用HttpResponseRedirect时,如何调用HttpResponseRedirectBase类

2024-04-18 19:50:04 发布

您现在位置:Python中文网/ 问答频道 /正文

当我调用这个函数时,我试图弄清楚HttpResponseRedirectBase是如何被调用的

return HttpResponseRedirect(next_page, context)

我相信这个问题与python的关系比Django更大,但是我找不到这个问题的答案是的。所以呢到目前为止,这就是我所看到的

class HttpResponseRedirect(HttpResponseRedirectBase):
    status_code = 302

现在我的问题是这里如何调用HttpResponseRedirectBase的初始值设定项?我试着模拟上述情况

class foo(object) :
  def __init__(self,par):
    print "Inside foo constructor"

class bar(foo):
  status_code = 302

b = bar(23)

我不确定在这种情况下如何调用foo的init?在这种情况下,我得到的错误

Traceback (most recent call last):
  File "python", line 5, in <module>
TypeError: Error when calling the metaclass bases
    function() argument 1 must be code, not str

任何帮助解决这个问题都将不胜感激。你知道吗


Tags: 函数returnfoo关系initstatuscontextpage