#16470: RFC5987/RFC6266 Support (Content-Disposition headers) -------------------------------+------------------------------------ Reporter: mnot@… | Owner: nobody Type: New feature | Status: new Component: HTTP handling | Version: 1.3 Severity: Normal | Resolution: Keywords: | Triage Stage: Accepted Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------+------------------------------------
Comment (by Claude Paroz): Now that we have a [https://docs.djangoproject.com/en/2.0/ref/request- response/#fileresponse-objects FileResponse] subclass, what about adding a parameter to this subclass which would then set the `Content-Disposition` header appropriately? Would that satisfy most use cases? The [https://docs.djangoproject.com/en/2.0/howto/outputting-pdf/ PDF output example] could be then rewritten as: {{{ import io from reportlab.pdfgen import canvas from django.http import FileResponse def some_view(request): # Create a file-like buffer to receive PDF data buffer = io.BytesIO() # Create the PDF object, using the buffer as its "file." p = canvas.Canvas(buffer) # Draw things on the PDF. Here's where the PDF generation happens. # See the ReportLab documentation for the full list of functionality. p.drawString(100, 100, "Hello world.") # Close the PDF object cleanly, and we're done. p.showPage() p.save() return FileResponse(buffer, as_attachment=True, filename="somefilename.pdf") }}} -- Ticket URL: <https://code.djangoproject.com/ticket/16470#comment:6> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/071.1e3a828fe2a4ef7dfbd889ceb686ae5c%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.