有一些相关问题,例如as this one,但答案似乎不起作用。
我的views.py
中有以下内容def pilab(request):
return render(request, 'pilab.html',{'foo':'bar'})
运行它并转到它的相应url会返回以下错误:
Traceback:
File "/data_nfs/opensurfaces2/venv/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
111. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/data_nfs/opensurfaces2/server/home/views.py" in pilab
31. return render(request, 'pilab.html',{'foo':'bar'})
File "/data_nfs/opensurfaces2/venv/local/lib/python2.7/site-packages/django/shortcuts.py" in render
50. return HttpResponse(loader.render_to_string(*args, **kwargs),
Exception Type: TypeError at /pilab/
Exception Value: render_to_string() got an unexpected keyword argument 'context'
扼杀,删除上下文字符串几乎会返回相同的错误:
Traceback:
File "/data_nfs/opensurfaces2/venv/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
111. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/data_nfs/opensurfaces2/server/home/views.py" in pilab
31. return render(request, 'pilab.html')
File "/data_nfs/opensurfaces2/venv/local/lib/python2.7/site-packages/django/shortcuts.py" in render
50. return HttpResponse(loader.render_to_string(*args, **kwargs),
Exception Type: TypeError at /pilab/
Exception Value: render_to_string() got an unexpected keyword argument 'context'
如何修复此错误?