jazzband / django-downloadview

Serve files with Django.
https://django-downloadview.readthedocs.io
Other
364 stars 58 forks source link

################### 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_:


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

urlpatterns = ('', url('^download/(?P[A-Za-z0-9-]+)/$', download, name='download'), )


Resources


.. _Django: https://djangoproject.com