HTTPDownloadView serves a file given an URL., i.e. it acts like a proxy.

This view is particularly handy when:

  • the client does not have access to the file resource, while your Django server does.
  • the client does trust your server, your server trusts a third-party, you do not want to bother the client with the third-party.

Simple example

Setup a view to stream files given URL:

from django_downloadview import HTTPDownloadView

class SimpleURLDownloadView(HTTPDownloadView):
    def get_url(self):
        """Return URL of hello-world.txt file on GitHub."""
        return '' \
               '/b7f660c5e3f37d918b106b02c5af7a887acc0111' \

simple_url = SimpleURLDownloadView.as_view()

Base options

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

API reference

class django_downloadview.views.http.HTTPDownloadView(**kwargs)

Bases: django_downloadview.views.base.BaseDownloadView

Proxy files that live on remote servers.

url = u''

URL to download (the one we are proxying).

request_kwargs = {}

Additional keyword arguments for request handler.


Return request factory to perform actual HTTP request.

Default implementation returns requests.get() callable.


Return keyword arguments for use with get_request_factory().

Default implementation returns request_kwargs.


Return remote file URL (the one we are proxying).

Default implementation returns url.


Return wrapper which has an url attribute.