2 回答
TA贡献1830条经验 获得超9个赞
我通过更改下面提到的代码解决了这个问题 -
def home(guts):
return TemplateResponse(template.render(mt_context1))
但是,这又引入了另一个错误。
不确定我是否可以在这里发布这个问题,但由于它似乎与此有关,我在下面提到它,任何对此的专业人士,我真的可以使用一些建议:)
追溯:
File "/home/gaurav/Desktop/a scratch/onenv/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner
34. response = get_response(request)
File "/home/gaurav/Desktop/a scratch/onenv/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
115. response = self.process_exception_by_middleware(e, request)
File "/home/gaurav/Desktop/a scratch/onenv/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
113. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/lib/python3.6/contextlib.py" in inner
52. return func(*args, **kwds)
File "/home/gaurav/Desktop/a scratch/onenv/lib/python3.6/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
21. return view_func(request, *args, **kwargs)
File "/home/gaurav/Desktop/a scratch/a/main/wrapper.py" in g
339. seed = d[request.method](guts, *args, **kwargs)
File "/home/gaurav/Desktop/a scratch/a/main/wrapper.py" in <lambda>
367. return dispatch_on_method(f, {"GET": lambda guts, *args, **kwargs: f(guts, *args, **kwargs)})
File "/home/gaurav/Desktop/a scratch/a/main/views/base.py" in home
104. return TemplateResponse(template.render(mt_context1))
异常类型:TypeError at / 异常值:init()缺少1个必需的位置参数:'data'
TA贡献2039条经验 获得超7个赞
您应该将传入请求传递给 TemplateResponse
def home(request): response = TemplateResponse(request, 'mytemplate.html', {'c_sk': c_nt,'d_sk_count': d_sk_count} ) return response
添加回答
举报