mirror of
https://github.com/jazzband/django-downloadview.git
synced 2026-05-28 08:48:23 +00:00
Removed deprecated DownloadView. Replaced by PathDownloadView and StorageDownloadView.
This commit is contained in:
parent
02f0b7aa0d
commit
58cf4bac7d
2 changed files with 4 additions and 29 deletions
|
|
@ -1,5 +1,8 @@
|
|||
"""django-downloadview provides generic download views for Django."""
|
||||
from django_downloadview.views import DownloadView, ObjectDownloadView
|
||||
# Shortcut import.
|
||||
from django_downloadview.views import (PathDownloadView,
|
||||
ObjectDownloadView,
|
||||
StorageDownloadView)
|
||||
|
||||
|
||||
pkg_resources = __import__('pkg_resources')
|
||||
|
|
|
|||
|
|
@ -128,34 +128,6 @@ class VirtualDownloadView():
|
|||
file_obj = None
|
||||
|
||||
|
||||
class DownloadView(BaseDownloadView):
|
||||
"""Download a file from storage and filename."""
|
||||
#: Server-side name (including path) of the file to serve.
|
||||
#:
|
||||
#: If ``storage`` is not None, then the filename will be passed to the
|
||||
#: storage, else filename is supposed to be an absolute filename of a file
|
||||
#: located on the local filesystem.
|
||||
filename = None
|
||||
|
||||
#: Storage to use to fetch the file.
|
||||
#:
|
||||
#: Defaults to Django's DefaultStorage(), which itself defaults to a
|
||||
#: FileSystemStorage relative to settings.MEDIA_ROOT.
|
||||
#:
|
||||
#: The ``storage`` can be set to None, but you should use one. As an
|
||||
#: example, storage classes may encapsulate some security checks
|
||||
#: (FileSystemStorage actually refuses to serve files outside its root
|
||||
#: location).
|
||||
storage = DefaultStorage()
|
||||
|
||||
def get_file(self):
|
||||
"""Use filename and storage to return file object to serve."""
|
||||
if self.storage:
|
||||
return StorageFile(self.storage, self.filename)
|
||||
else:
|
||||
return File(open(self.filename))
|
||||
|
||||
|
||||
class ObjectDownloadView(DownloadMixin, BaseDetailView):
|
||||
"""Download view for models which contain a FileField.
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue