StorageDownloadView serves 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.

Simple example

Given a storage:

from import FileSystemStorage

storage = FileSystemStorage()

Setup a view to stream files in storage:

from django_downloadview import StorageDownloadView

static_path = StorageDownloadView.as_view(storage=storage)

The view accepts a path argument you can setup either in as_view or via URLconfs:

from django.conf.urls import patterns, url

from import views

urlpatterns = patterns(

Base options

StorageDownloadView inherits from DownloadMixin, which has various options such as basename or attachment.

Computing path dynamically

Override the StorageDownloadView.get_path() method to adapt path resolution to your needs.

As an example, here is the same view as above, but the path is converted to uppercase:

from django_downloadview import StorageDownloadView

class DynamicStorageDownloadView(StorageDownloadView):
    """Serve file of storage by path.upper()."""
    def get_path(self):
        """Return uppercase path."""
        return super(DynamicStorageDownloadView, self).get_path().upper()

dynamic_path = DynamicStorageDownloadView.as_view(storage=storage)

API reference


Bases: django_downloadview.views.path.PathDownloadView

Serve a file using storage and filename.

storage = < object>

Storage the file to serve belongs to.

path = None

Path to the file to serve relative to storage.


Return path of the file to serve, relative to storage.

Default implementation simply returns view’s path attribute.

Override this method if you want custom implementation.


Return StorageFile instance.