diff --git a/demo/demoproject/object/views.py b/demo/demoproject/object/views.py index e7525b6..2675a6a 100644 --- a/demo/demoproject/object/views.py +++ b/demo/demoproject/object/views.py @@ -17,7 +17,7 @@ deserialized_basename_view = ObjectDownloadView.as_view( model=Document, basename_field='basename') -#: Serve ``file`` attribute of ``Document`` model, inline rather than as attachment +#: Serve ``file`` attribute of ``Document`` model, inline (not as attachment). inline_file_view = ObjectDownloadView.as_view( model=Document, attachment=False) diff --git a/docs/views/object.txt b/docs/views/object.txt index f78f1ae..0b71cbe 100644 --- a/docs/views/object.txt +++ b/docs/views/object.txt @@ -61,18 +61,30 @@ 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 +Serving a file inline rather than as attachment *********************************************** -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. +You can setup :attr:`~django_downloadview.views.base.DownloadMixin.attachment` +to make a view serve a file inline rather than as attachment: + +* ``attachment`` is ``False``: inline file, which content is displayed inside + the browser, as if it was an element of the current page. + +* ``attachment`` is ``True`` (default): attached file, which usually triggers a + download, i.e. the user is prompted to "save the file as ...". .. literalinclude:: /../demo/demoproject/object/views.py :language: python :lines: 1-5, 20-23 +.. note:: + + The actual behaviour client-side depends on browsers and their + configuration. + + ********************************** Mapping file attributes to model's **********************************