Configure¶
Here is the list of Django settings for django-downloadview.
INSTALLED_APPS¶
There is no need to register this application in INSTALLED_APPS
.
MIDDLEWARE_CLASSES¶
If you plan to setup reverse-proxy optimizations,
add django_downloadview.SmartDownloadMiddleware
to MIDDLEWARE_CLASSES
.
It is a response middleware. Move it after middlewares that compute the
response content such as gzip middleware.
Example:
MIDDLEWARE_CLASSES = [
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django_downloadview.SmartDownloadMiddleware'
]
DOWNLOADVIEW_BACKEND¶
This setting is used by
SmartDownloadMiddleware
.
It is the import string of a callable (typically a class) of an optimization
backend (typically a BaseDownloadMiddleware
subclass).
Example:
DOWNLOADVIEW_BACKEND = 'django_downloadview.nginx.XAccelRedirectMiddleware'
See Optimize streaming for a list of available backends (middlewares).
When django_downloadview.SmartDownloadMiddleware
is in your
MIDDLEWARE_CLASSES
, this setting must be explicitely configured (no default
value). Else, you can ignore this setting.
DOWNLOADVIEW_RULES¶
This setting is used by
SmartDownloadMiddleware
.
It is a list of positional arguments or keyword arguments that will be used to
instanciate class mentioned as DOWNLOADVIEW_BACKEND
.
Each item in the list can be either a list of positional arguments, or a dictionary of keyword arguments. One item cannot contain both positional and keyword arguments.
Here is an example containing one rule using keyword arguments:
DOWNLOADVIEW_RULES = [
{
'source_url': '/media/nginx/',
'destination_url': '/nginx-optimized-by-middleware/',
},
]
See Optimize streaming for details about builtin backends (middlewares) and their options.
When django_downloadview.SmartDownloadMiddleware
is in your
MIDDLEWARE_CLASSES
, this setting must be explicitely configured (no default
value). Else, you can ignore this setting.