when I want to print order detail as PDF file it give the following:
The error:
admin_order_pdf() got an unexpected keyword argument 'order'
the function:
@staff_member_required
def admin_order_pdf(request, order_id):
order = get_object_or_404(Order, id=order_id)
html = render_to_string('orders/pdf.html', {'order': order})
response = HttpResponse(content_type='application/pdf')
response['Content-Disposition'] = f'filename=order_{order.id}.pdf'
weasyprint.HTML(string=html).write_pdf(response,
stylesheets=[weasyprint.CSS(
settings.STATIC_ROOT + 'css/pdf.css'
)])
return response
Aucun commentaire:
Enregistrer un commentaire