来自继承类的访问请求(视图)



如果我不实现从继承类(视图)获取/发布的方法,我如何访问var请求?

class Base(View): 
    def __init__(self):
          self.menu="options": [
            {
                "link": "home:IndexHome",
                "name": "Base",
                "class": "icon-dashboard",
                "section" : "home",
            },
            {
                "link": "reports:IndexReports",
                "name": "Informes",
                "class": "icon-list-alt",
                "section":"reports",
            }]}
   def somemethod(self):
           request.session['idsession']

如果某些视图继承自 Base 会发生什么?喜欢这个。

class login(Base):
def __init__(self):
    Base.__init__(self)

错误是:"登录"对象没有属性"请求"

非常感谢。

request对象可用作View实例的属性:

def somemethod(self):
    self.request.session['idsession']

最新更新