March 2020
Intermediate to advanced
608 pages
17h 17m
English
Follow these steps to complete the recipe:
# myproject/apps/ideas/views.pyfrom django.shortcuts import get_object_or_404from .models import Ideadef idea_handout_pdf(request, pk): from django.template.loader import render_to_string from django.utils.timezone import now as timezone_now from django.utils.text import slugify from django.http import HttpResponse from weasyprint import HTML from weasyprint.fonts import FontConfiguration idea = get_object_or_404(Idea, pk=pk) context = {"idea": idea} html = render_to_string( "ideas/idea_handout_pdf.html", context ) response = HttpResponse(content_type="application/pdf") response[ "Content-Disposition" ] = "inline; filename={date}-{name}-handout.pdf".format( ...