On 9/30/05, David S. <[EMAIL PROTECTED]> wrote: > I am wondering how best to serve PDF files in Django. > > I am using ReportLab to generate a file.
It's entirely possible to serve PDF files dynamically using Django. I've done this in the past, generating NCAA tournament brackets dynamically for people in a March Madness tournament. The key is to remember HttpResponse objects are file-like objects, so you can do this in your view: from reportlab.pdfgen import canvas response = HttpResponse(mimetype='application/pdf') response['Content-Disposition'] = 'attachment; filename=foo.pdf' p = canvas.Canvas(response) p.drawString(100, 100, "Hello world") p.showPage() p.save() return response I'll have this documented on djangoproject.com by the end of the day. Adrian -- Adrian Holovaty holovaty.com | djangoproject.com | chicagocrime.org