I am getting the error "render() takes exactly 2 arguments (1 given)" after migrating my application to new server. Here is content of my urls.py file:
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^warlist/', include('warlist.urls')),
url(r'^warlist/(?P<path>.*)$', serve,{'document_root': settings.MEDIA_ROOT}),
]
and in my views.py i am doing below:
template = loader.get_template('warlist/index.html')
image = loader.get_template('warlist/image.html')
table = loader.get_template('warlist/welcomepage_table.html')
info = loader.get_template('warlist/info.html')
return HttpResponse(image.render()+ template.render()+info.render()+table.render()+info_str+table_str)
The above application is working fine in my old server with given code.
When you call render():
return HttpResponse(image.render()+ template.render()+info.render()+table.render()+info_str+table_str)
You need to pass the context into the render() method.
It means that .render() expects an argument. The 1 given is the object on which you call the method. For instance image.render() will have the definition def render(self, argument): where the self is the image object on which you call the method.
render takes something like this
return render(request,'template_name.html',context)
if you are trying to use HttpResponse. create one html file and the rest you want to include, include them like this include('addition.html') in your 'template_name.html' and then return the HttpResponse.