Django render_to_string()为参数';获取了多个值;上下文';
我正在尝试传递以下参数以在Django中呈现响应语法,但我一直遇到以下错误:Django render_to_string()为参数';获取了多个值;上下文';,django,Django,我正在尝试传递以下参数以在Django中呈现响应语法,但我一直遇到以下错误: render_to_string() got multiple values for argument 'context' def genarate_pdf_notes(request): response = HttpResponse(content_type='application/pdf') response['Content-Disposition'] = 'attachment; file
render_to_string() got multiple values for argument 'context'
def genarate_pdf_notes(request):
response = HttpResponse(content_type='application/pdf')
response['Content-Disposition'] = 'attachment; filename=filter' + \
str(datetime.datetime.now())+'.pdf'
response['Content-Transfer-Encoding'] = 'binary'
context = {}
filtered_yp = YP_Filter(
request.GET,
queryset=YP_General_Information.objects.all()
)
context['filtered_yp'] = filtered_yp
html_string = render_to_string(request, 'filter/homepage.html', context=context)
html = HTML(string=html_string)
result = html.write_pdf()
with tempfile.NamedTemporaryFile(delete=True) as output:
output.write(result)
output.flush()
output.seek(0)
# output = open(output.name, 'rb') they using this on a live server
response.write(output.read())
return response