I need to modify the render_pdf so that it receives the data that is stored in a list, since currently it does not show me any information. my code is this:
Views.py
class PDFprueba(View):
def get(self,request,*args,**kwargs):
datos = []
for mascota in Mascota.objects.all() :
datos.append(
{
'nombre' : mascota.nombre,
'sexo' : mascota.sexo,
}
)
return render_pdf('pdf/pdf.html',{'datos': datos})
render_pdf
def render_pdf(template_src, context_dict):
template = get_template(template_src)
html = template.render(context_dict)
result = BytesIO()
pdf = pisa.pisaDocument(BytesIO(html.encode('UTF-8')), result)
if not pdf.err:
return HttpResponse(result.getvalue(), content_type='application/pdf')
return HttpResponse('We had some errors<pre>%s</pre>' % escape(html))