def preview_pdf(request, did):
d_instance = get_object_or_404(MyObject, pk=did, user=request.user)
#resp = HttpResponse(content_type='application/pdf')
result = generate_pdf('pdf_preview.html')
return render_to_response('pdf_preview.html', {'objects': d_instance,'result':result}, RequestContext(request))
pdf_preview.html:
{{result}}
<iframe src="http://docs.google.com/viewer?url={{result}}.pdf&embedded=true" width="600" height="780" style="border: none;"></iframe>
{{objects.name}}
但不显示文档。
{{result}}
显示如下:<StringIO.StringIO instance at 0xb4da030c>