From 558bd757a3b9a07b6d2246fb5aca698f5c0f2a33 Mon Sep 17 00:00:00 2001 From: Erik Dykema Date: Mon, 10 Feb 2014 14:29:48 -0500 Subject: [PATCH 1/2] Add non-downloading inline_file_view To be used in documentation for issue #80 --- demo/demoproject/object/views.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/demo/demoproject/object/views.py b/demo/demoproject/object/views.py index d512ed8..e7525b6 100644 --- a/demo/demoproject/object/views.py +++ b/demo/demoproject/object/views.py @@ -16,3 +16,8 @@ another_file_view = ObjectDownloadView.as_view( deserialized_basename_view = ObjectDownloadView.as_view( model=Document, basename_field='basename') + +#: Serve ``file`` attribute of ``Document`` model, inline rather than as attachment +inline_file_view = ObjectDownloadView.as_view( + model=Document, + attachment=False) From 21cb8f6409d1429a26ed7ba4d2abf9ee63dcc949 Mon Sep 17 00:00:00 2001 From: Erik Dykema Date: Mon, 10 Feb 2014 14:30:41 -0500 Subject: [PATCH 2/2] Add documentation for serving a file inline. Responsive to issue #80 --- docs/views/object.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/views/object.txt b/docs/views/object.txt index 955d960..f78f1ae 100644 --- a/docs/views/object.txt +++ b/docs/views/object.txt @@ -61,6 +61,18 @@ Then here is the code to serve "another_file" instead of the default "file": :language: python :lines: 1-5, 10-12 +*********************************************** +Serving a file inline rather than as a download +*********************************************** + +If you would prefer to serve a file as an element of an exsting page +rather than triggering a download, you can use :attr:`ObjectDownloadView.attachment` to specify +that the HTTP Response object should not have the attachment attribute. + +.. literalinclude:: /../demo/demoproject/object/views.py + :language: python + :lines: 1-5, 20-23 + ********************************** Mapping file attributes to model's **********************************