def pdf(request):
    with open('example.pdf', 'wb') as f2:
        f2.write(render_to_pdf('you template', {'user': request.user},
            encoding='utf-8'))
Generate PDF from HTML using Django and Reportlab