Skip to main content

Generic download views for Django.

Project description

Django-DownloadView provides generic views to make Django serve files.

It can serve files from models, storages, local filesystem, arbitrary URL… and even generated files.

For increased performances, it can delegate the actual streaming to a reverse proxy, via mechanisms such as Nginx’s X-Accel.

Example

In some urls.py, serve files managed in a model:

from django.conf.urls import url, url_patterns
from django_downloadview import ObjectDownloadView
from demoproject.download.models import Document  # A model with a FileField

# ObjectDownloadView inherits from django.views.generic.BaseDetailView.
download = ObjectDownloadView.as_view(model=Document, file_field='file')

url_patterns = ('',
    url('^download/(?P<slug>[A-Za-z0-9_-]+)/$', download, name='download'),
)

More examples in the “demo” documentation!

Views

Several views are provided to cover frequent use cases:

  • ObjectDownloadView when you have a model with a file field.

  • StorageDownloadView when you manage files in a storage.

  • PathDownloadView when you have an absolute filename on local filesystem.

  • HTTPDownloadView when you have an URL (the resource is proxied).

  • VirtualDownloadView when you the file is generated on the fly.

See “views” documentation for details.

See also “optimizations” documentation to get increased performances.

Ressources

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-downloadview-1.2.zip (22.6 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page