1

There are a few related questions, such as this one, but the answers do not appear to work.

I have the following in my views.py

def pilab(request):
    return render(request, 'pilab.html',{'foo':'bar'})

Running this and going to it's corresponding url returns the following error:

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'

Strangly enough, removing the context string returns virtually the same error:

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'

How can this error be fixed?

Mitchell van Zuylen
  • 3,905
  • 4
  • 27
  • 64

0 Answers0