Debian Codegraph @

demo/demoproject/settings.py

raw
1 """Django settings for django-downloadview demo project."""
2
3 import os
4
5
6 # Configure some relative directories.
7 demoproject_dir = os.path.dirname(os.path.abspath(__file__))
8 demo_dir = os.path.dirname(demoproject_dir)
9 root_dir = os.path.dirname(demo_dir)
10 data_dir = os.path.join(root_dir, "var")
11 cfg_dir = os.path.join(root_dir, "etc")
12
13
14 # Mandatory settings.
15 ROOT_URLCONF = "demoproject.urls"
16 WSGI_APPLICATION = "demoproject.wsgi.application"
17
18
19 # Database.
20 DATABASES = {
21 "default": {
22 "ENGINE": "django.db.backends.sqlite3",
23 "NAME": os.path.join(data_dir, "db.sqlite"),
24 }
25 }
26
27
28 # Required.
29 SECRET_KEY = "This is a secret made public on project's repository."
30
31 # Media and static files.
32 MEDIA_ROOT = os.path.join(data_dir, "media")
33 MEDIA_URL = "/media/"
34 STATIC_ROOT = os.path.join(data_dir, "static")
35 STATIC_URL = "/static/"
36
37
38 # Applications.
39 INSTALLED_APPS = (
40 # The actual django-downloadview demo.
41 "demoproject",
42 "demoproject.object", # Demo around ObjectDownloadView
43 "demoproject.storage", # Demo around StorageDownloadView
44 "demoproject.path", # Demo around PathDownloadView
45 "demoproject.http", # Demo around HTTPDownloadView
46 "demoproject.virtual", # Demo around VirtualDownloadView
47 "demoproject.nginx", # Sample optimizations for Nginx X-Accel.
48 "demoproject.apache", # Sample optimizations for Apache X-Sendfile.
49 "demoproject.lighttpd", # Sample optimizations for Lighttpd X-Sendfile.
50 # Standard Django applications.
51 "django.contrib.auth",
52 "django.contrib.contenttypes",
53 "django.contrib.sessions",
54 "django.contrib.sites",
55 "django.contrib.messages",
56 "django.contrib.staticfiles",
57 )
58
59
60 # BEGIN middlewares
61 MIDDLEWARE = [
62 "django.middleware.common.CommonMiddleware",
63 "django.contrib.sessions.middleware.SessionMiddleware",
64 "django.middleware.csrf.CsrfViewMiddleware",
65 "django.contrib.auth.middleware.AuthenticationMiddleware",
66 "django.contrib.messages.middleware.MessageMiddleware",
67 "django_downloadview.SmartDownloadMiddleware",
68 ]
69 # END middlewares
70
71
72 # Specific configuration for django_downloadview.SmartDownloadMiddleware.
73 # BEGIN backend
74 DOWNLOADVIEW_BACKEND = "django_downloadview.nginx.XAccelRedirectMiddleware"
75 # END backend
76 """Could also be:
77 DOWNLOADVIEW_BACKEND = 'django_downloadview.apache.XSendfileMiddleware'
78 DOWNLOADVIEW_BACKEND = 'django_downloadview.lighttpd.XSendfileMiddleware'
79 """
80
81 # BEGIN rules
82 DOWNLOADVIEW_RULES = [
83 {
84 "source_url": "/media/nginx/",
85 "destination_url": "/nginx-optimized-by-middleware/",
86 },
87 ]
88 # END rules
89 DOWNLOADVIEW_RULES += [
90 {
91 "source_url": "/media/apache/",
92 "destination_dir": "/apache-optimized-by-middleware/",
93 # Bypass global default backend with additional argument "backend".
94 # Notice that in general use case, ``DOWNLOADVIEW_BACKEND`` should be
95 # enough. Here, the django_downloadview demo project needs to
96 # demonstrate usage of several backends.
97 "backend": "django_downloadview.apache.XSendfileMiddleware",
98 },
99 {
100 "source_url": "/media/lighttpd/",
101 "destination_dir": "/lighttpd-optimized-by-middleware/",
102 # Bypass global default backend with additional argument "backend".
103 # Notice that in general use case, ``DOWNLOADVIEW_BACKEND`` should be
104 # enough. Here, the django_downloadview demo project needs to
105 # demonstrate usage of several backends.
106 "backend": "django_downloadview.lighttpd.XSendfileMiddleware",
107 },
108 ]
109
110
111 # Test/development settings.
112 DEBUG = True
113
114
115 TEMPLATES = [
116 {
117 "BACKEND": "django.template.backends.django.DjangoTemplates",
118 "DIRS": [os.path.join(os.path.dirname(__file__), "templates")],
119 "OPTIONS": {
120 "debug": DEBUG,
121 "context_processors": [
122 # Insert your TEMPLATE_CONTEXT_PROCESSORS here or use this
123 # list if you haven't customized them:
124 "django.contrib.auth.context_processors.auth",
125 "django.template.context_processors.debug",
126 "django.template.context_processors.i18n",
127 "django.template.context_processors.media",
128 "django.template.context_processors.static",
129 "django.template.context_processors.tz",
130 "django.contrib.messages.context_processors.messages",
131 ],
132 },
133 },
134 ]