Serve files with Django.
Find a file
Benoît Bryon f69458afcb Merge pull request #33 from novagile/master
Closes #32 - X-Accel + attachment=False
2013-05-06 07:56:23 -07:00
demo Refs #32 - Respect 'attachment' argument in X-Accel optimization. 2013-05-06 16:50:47 +02:00
django_downloadview Refs #32 - Respect 'attachment' argument in X-Accel optimization. 2013-05-06 16:50:47 +02:00
docs Reviewed documentation. 2013-04-11 15:42:28 +02:00
etc Frozen version of evg.recipe.activate in development environment. 2013-05-06 16:48:49 +02:00
.gitignore Improved Makefile + some other minor improvements 2013-03-20 16:21:48 +01:00
.travis.yml Added support for TravisCI.org. 2013-03-20 16:22:38 +01:00
AUTHORS Improved Makefile + some other minor improvements 2013-03-20 16:21:48 +01:00
CHANGELOG Back to development: 1.2 2013-04-11 15:57:47 +02:00
INSTALL Reviewed documentation. 2013-04-11 15:02:45 +02:00
LICENSE Improved Makefile + some other minor improvements 2013-03-20 16:21:48 +01:00
Makefile Improved Makefile + some other minor improvements 2013-03-20 16:21:48 +01:00
MANIFEST.in Reviewed documentation. Preparing first public release. 2012-12-04 11:47:37 +01:00
README Reviewed documentation. 2013-04-11 15:42:28 +02:00
setup.py Refs #29 - Introduced HTTPFile and HTTPDownloadView to create proxy to arbitrary HTTP URL. 2013-04-08 15:39:06 +02:00
VERSION Back to development: 1.2 2013-04-11 15:57:47 +02:00

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

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 :file:`urls.py`, serve files managed in a model:

.. code-block:: 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'),
   )

More examples in the :doc:`demo project <demo>`!


*****
Views
*****

Several views are provided to cover frequent use cases:

* ``ObjectDownloadView`` to serve some file field of a model.
* ``StorageDownloadView`` to serve files in a storage, without models.
* ``PathDownloadView`` to serve files located on local filesystem, without
  storage.
* ``HTTPDownloadView`` to proxy some arbitrary URL.
* ``VirtualDownloadView`` to serve in-memory or generated files.

See :doc:`views` for details.

Then get increased performances with :doc:`optimizations/index`.
 

**********
Ressources
**********

* Documentation: http://django-downloadview.readthedocs.org
* PyPI page: http://pypi.python.org/pypi/django-downloadview
* Code repository: https://github.com/benoitbryon/django-downloadview
* Bugtracker: https://github.com/benoitbryon/django-downloadview/issues
* Continuous integration: https://travis-ci.org/benoitbryon/django-downloadview