mirror of
https://github.com/jazzband/django-downloadview.git
synced 2026-03-16 22:40:25 +00:00
48 lines
1.4 KiB
Text
48 lines
1.4 KiB
Text
##############
|
|
Download views
|
|
##############
|
|
|
|
This section contains narrative overview about class-based views provided by
|
|
django-downloadview.
|
|
|
|
|
|
****************
|
|
PathDownloadView
|
|
****************
|
|
|
|
The :py:class:`django_downloadview.views.PathDownloadView` class-based view
|
|
allows you to **serve files given an absolute path on local filesystem**.
|
|
|
|
Two main use cases:
|
|
|
|
* as a shortcut. This dead-simple view is straight to call, so you can use it
|
|
to simplify code in more complex views, provided you have an absolute path to
|
|
a local file.
|
|
|
|
* override. Extend :py:class:`django_downloadview.views.PathDownloadView` and
|
|
override :py:meth:`django_downloadview.views.PathDownloadView:get_path`.
|
|
|
|
|
|
*******************
|
|
StorageDownloadView
|
|
*******************
|
|
|
|
The :py:class:`django_downloadview.views.StorageDownloadView` class-based view
|
|
allows you to **serve files given a storage and a path**.
|
|
|
|
Use this view when you manage files in a storage (which is a good practice),
|
|
unrelated to a model.
|
|
|
|
|
|
******************
|
|
ObjectDownloadView
|
|
******************
|
|
|
|
The :py:class:`django_downloadview.views.ObjectDownloadView` class-based view
|
|
allows you to **serve files given a model with some file fields** such as
|
|
FileField or ImageField.
|
|
|
|
Use this view anywhere you could use Django's builtin ObjectDetailView.
|
|
|
|
Some options allow you to store file metadata (size, content-type, ...) in the
|
|
model, as deserialized fields.
|