Serve files with Django.
Find a file
pre-commit-ci[bot] 34a83fd09b
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/pre-commit/mirrors-eslint: v9.38.0 → v9.39.1](https://github.com/pre-commit/mirrors-eslint/compare/v9.38.0...v9.39.1)
- [github.com/astral-sh/ruff-pre-commit: v0.14.2 → v0.14.4](https://github.com/astral-sh/ruff-pre-commit/compare/v0.14.2...v0.14.4)
- [github.com/tox-dev/pyproject-fmt: v2.11.0 → v2.11.1](https://github.com/tox-dev/pyproject-fmt/compare/v2.11.0...v2.11.1)
2025-11-10 17:38:43 +00:00
.github Add test matrix 2025-10-21 09:53:13 +02:00
demo Run pre-commit on all files 2024-08-05 10:53:19 +02:00
django_downloadview [pre-commit.ci] auto fixes from pre-commit.com hooks 2025-10-20 19:50:02 +00:00
docs Run pre-commit on all files 2024-08-05 10:53:19 +02:00
tests [pre-commit.ci] auto fixes from pre-commit.com hooks 2025-10-20 19:50:02 +00:00
.gitignore Drop support for end of life Django settings in demo project 2021-01-21 11:28:40 -05:00
.isort.cfg Migrate to GitHub Actions. (#165) 2020-12-23 11:12:35 +01:00
.pre-commit-config.yaml [pre-commit.ci] pre-commit autoupdate 2025-11-10 17:38:43 +00:00
.readthedocs.yaml Add readthedocs config 2024-08-05 10:50:24 +02:00
AUTHORS Update AUTHORS 2024-08-05 14:03:55 +02:00
CHANGELOG Post release 2025-10-28 11:34:20 +01:00
CODE_OF_CONDUCT.md Jazzband: Created local 'CODE_OF_CONDUCT.md' from remote 'CODE_OF_CONDUCT.md' 2022-02-17 11:46:17 +01:00
CONTRIBUTING.rst Run pre-commit on all files 2024-08-05 10:53:19 +02:00
INSTALL Drop Python 3.6 support 2022-08-04 09:22:28 -04:00
LICENSE Refs #74 - Switched to tox as test-environment manager. Added flake8 to the test suite. Dropped python 2.6 tests. Makefile no longer creates a virtualenv. 2014-02-10 01:27:14 +01:00
Makefile Migrate to GitHub Actions. (#165) 2020-12-23 11:12:35 +01:00
MANIFEST.in Migrate to GitHub Actions. (#165) 2020-12-23 11:12:35 +01:00
README.rst Run pre-commit on all files 2024-08-05 10:53:19 +02:00
setup.py Upgrade to Django 5.2 and Python 3.14 2025-10-21 09:52:06 +02:00
tox.ini Upgrade test matrix 2025-10-21 10:36:39 +02:00

###################
django-downloadview
###################

.. image:: https://jazzband.co/static/img/badge.svg
    :target: https://jazzband.co/
    :alt: Jazzband

.. image:: https://img.shields.io/pypi/v/django-downloadview.svg
    :target: https://pypi.python.org/pypi/django-downloadview

.. image:: https://img.shields.io/pypi/pyversions/django-downloadview.svg
    :target: https://pypi.python.org/pypi/django-downloadview

.. image:: https://img.shields.io/pypi/djversions/django-downloadview.svg
    :target: https://pypi.python.org/pypi/django-downloadview

.. image:: https://img.shields.io/pypi/dm/django-downloadview.svg
    :target: https://pypi.python.org/pypi/django-downloadview

.. image:: https://github.com/jazzband/django-downloadview/workflows/Test/badge.svg
    :target: https://github.com/jazzband/django-downloadview/actions
    :alt: GitHub Actions

.. image:: https://codecov.io/gh/jazzband/django-downloadview/branch/master/graph/badge.svg
    :target: https://codecov.io/gh/jazzband/django-downloadview
    :alt: Coverage

``django-downloadview`` makes it easy to serve files with `Django`_:

* you manage files with Django (permissions, filters, generation, ...);

* files are stored somewhere or generated somehow (local filesystem, remote
  storage, memory...);

* ``django-downloadview`` helps you stream the files with very little code;

* ``django-downloadview`` helps you improve performances with reverse proxies,
  via mechanisms such as Nginx's X-Accel or Apache's X-Sendfile.


*******
Example
*******

Let's serve a file stored in a file field of some model:

.. code:: python

   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'),
   )


*********
Resources
*********

* Documentation: https://django-downloadview.readthedocs.io
* PyPI page: http://pypi.python.org/pypi/django-downloadview
* Code repository: https://github.com/jazzband/django-downloadview
* Bugtracker: https://github.com/jazzband/django-downloadview/issues
* Continuous integration: https://github.com/jazzband/django-downloadview/actions
* Roadmap: https://github.com/jazzband/django-downloadview/milestones

.. _`Django`: https://djangoproject.com