如果我没有从继承类(视图)实现get / post方法,我如何访问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)
错误是:'登录'对象没有属性'请求'
很多。
答案 0 :(得分:1)
request
对象可用作View
实例的属性:
def somemethod(self):
self.request.session['idsession']