mirror of
https://github.com/jazzband/django-downloadview.git
synced 2026-03-16 22:40:25 +00:00
| .. | ||
| demoproject | ||
| README | ||
| setup.py | ||
############
Demo project
############
The :file:`demo/` folder holds a demo project to illustrate django-downloadview
usage.
***********************
Browse demo code online
***********************
See `demo folder in project's repository`_.
***************
Deploy the demo
***************
System requirements:
* `Python`_ version 2.6 or 2.7, available as ``python`` command.
.. note::
You may use `Virtualenv`_ to make sure the active ``python`` is the right
one.
* ``make`` and ``wget`` to use the provided :file:`Makefile`.
Execute:
.. code-block:: sh
git clone git@github.com:benoitbryon/django-downloadview.git
cd django-downloadview/
make demo
It installs and runs the demo server on localhost, port 8000. So have a look
at http://localhost:8000/
.. note::
If you cannot execute the Makefile, read it and adapt the few commands it
contains to your needs.
Browse and use :file:`demo/demoproject/` as a sandbox.
*********************************
Base example provided in the demo
*********************************
In the "demoproject" project, there is an application called "download".
:file:`demo/demoproject/settings.py`:
.. literalinclude:: ../demo/demoproject/settings.py
:language: python
:lines: 33-49
:emphasize-lines: 44
This application holds a ``Document`` model.
:file:`demo/demoproject/download/models.py`:
.. literalinclude:: ../demo/demoproject/download/models.py
:language: python
.. note::
The ``storage`` is the default one, i.e. it uses ``settings.MEDIA_ROOT``.
Combined to this ``upload_to`` configuration, files for ``Document`` model
live in :file:`var/media/document/` folder, relative to your
django-downloadview clone root.
There is a download view named "download_document" for this model:
:file:`demo/demoproject/download/urls.py`:
.. literalinclude:: ../demo/demoproject/download/urls.py
:language: python
As is, Django is to serve the files, i.e. load chunks into memory and stream
them.
**********
References
**********
.. target-notes::
.. _`demo folder in project's repository`:
https://github.com/benoitbryon/django-downloadview/tree/master/demo/demoproject/
.. _`Python`: http://python.org
.. _`Virtualenv`: http://virtualenv.org