|
1 | | -""" |
2 | | -Django settings for gettingstarted project. |
3 | | -
|
4 | | -Generated by 'django-admin startproject' using Django 2.0. |
5 | | -
|
6 | | -For more information on this file, see |
7 | | -https://docs.djangoproject.com/en/2.0/topics/settings/ |
8 | | -
|
9 | | -For the full list of settings and their values, see |
10 | | -https://docs.djangoproject.com/en/2.0/ref/settings/ |
11 | | -""" |
12 | 1 |
|
13 | 2 | import os |
| 3 | +import dj_database_url |
14 | 4 | import django_heroku |
15 | 5 |
|
16 | | - |
17 | 6 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...) |
18 | | -BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
19 | | - |
20 | | - |
21 | | -# Quick-start development settings - unsuitable for production |
22 | | -# See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/ |
23 | | - |
24 | | -# SECURITY WARNING: keep the secret key used in production secret! |
25 | | -SECRET_KEY = 'CHANGE_ME!!!! (P.S. the SECRET_KEY environment variable will be used, if set, instead).' |
26 | | - |
27 | | -# SECURITY WARNING: don't run with debug turned on in production! |
28 | | -DEBUG = True |
29 | | - |
30 | | -ALLOWED_HOSTS = [] |
| 7 | +BASE_DIR = os.path.dirname(os.path.dirname(__file__)) |
31 | 8 |
|
32 | 9 |
|
33 | 10 | # Application definition |
|
38 | 15 | 'django.contrib.contenttypes', |
39 | 16 | 'django.contrib.sessions', |
40 | 17 | 'django.contrib.messages', |
| 18 | + 'whitenoise.runserver_nostatic', |
41 | 19 | 'django.contrib.staticfiles', |
42 | | - 'core' |
| 20 | + 'core', |
43 | 21 | ] |
44 | 22 |
|
45 | 23 | MIDDLEWARE = [ |
46 | 24 | 'django.middleware.security.SecurityMiddleware', |
| 25 | + 'whitenoise.middleware.WhiteNoiseMiddleware', |
47 | 26 | 'django.contrib.sessions.middleware.SessionMiddleware', |
48 | 27 | 'django.middleware.common.CommonMiddleware', |
49 | 28 | 'django.middleware.csrf.CsrfViewMiddleware', |
|
52 | 31 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', |
53 | 32 | ] |
54 | 33 |
|
55 | | -ROOT_URLCONF = 'config.urls' |
56 | | - |
57 | 34 | TEMPLATES = [ |
58 | 35 | { |
59 | 36 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', |
|
70 | 47 | }, |
71 | 48 | ] |
72 | 49 |
|
73 | | -WSGI_APPLICATION = 'config.wsgi.application' |
74 | | - |
75 | | - |
76 | 50 | # Database |
77 | | -# https://docs.djangoproject.com/en/2.0/ref/settings/#databases |
| 51 | +# https://docs.djangoproject.com/en/1.11/ref/settings/#databases |
78 | 52 |
|
79 | 53 | DATABASES = { |
80 | 54 | 'default': { |
81 | 55 | 'ENGINE': 'django.db.backends.sqlite3', |
82 | 56 | 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), |
83 | 57 | } |
| 58 | + |
84 | 59 | } |
85 | 60 |
|
| 61 | +# for dj_database_url |
| 62 | +db_from_env = dj_database_url.config() |
| 63 | +DATABASES['default'].update(db_from_env) |
| 64 | + |
86 | 65 |
|
87 | 66 | # Password validation |
88 | | -# https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators |
| 67 | +# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators |
89 | 68 |
|
90 | 69 | AUTH_PASSWORD_VALIDATORS = [ |
91 | 70 | { |
|
103 | 82 | ] |
104 | 83 |
|
105 | 84 |
|
| 85 | +# Static files (CSS, JavaScript, Images) |
| 86 | +# https://docs.djangoproject.com/en/1.11/howto/static-files/ |
| 87 | + |
| 88 | +STATIC_URL = '/static/' |
| 89 | +STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') |
| 90 | +STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' |
| 91 | + |
| 92 | +# SECURITY WARNING: keep the secret key used in production secret! |
| 93 | +SECRET_KEY = 'CHANGE_ME!!!! (P.S. the SECRET_KEY environment variable will be used, if set, instead).' |
| 94 | + |
| 95 | +# SECURITY WARNING: don't run with debug turned on in production! |
| 96 | +DEBUG = True |
| 97 | + |
| 98 | +ALLOWED_HOSTS = [] |
| 99 | + |
| 100 | + |
| 101 | +# Application definition |
| 102 | + |
| 103 | +INSTALLED_APPS = [ |
| 104 | + 'django.contrib.admin', |
| 105 | + 'django.contrib.auth', |
| 106 | + 'django.contrib.contenttypes', |
| 107 | + 'django.contrib.sessions', |
| 108 | + 'django.contrib.messages', |
| 109 | + 'django.contrib.staticfiles', |
| 110 | + 'core' |
| 111 | +] |
| 112 | + |
| 113 | +MIDDLEWARE = [ |
| 114 | + 'django.middleware.security.SecurityMiddleware', |
| 115 | + 'django.contrib.sessions.middleware.SessionMiddleware', |
| 116 | + 'django.middleware.common.CommonMiddleware', |
| 117 | + 'django.middleware.csrf.CsrfViewMiddleware', |
| 118 | + 'django.contrib.auth.middleware.AuthenticationMiddleware', |
| 119 | + 'django.contrib.messages.middleware.MessageMiddleware', |
| 120 | + 'django.middleware.clickjacking.XFrameOptionsMiddleware', |
| 121 | +] |
| 122 | + |
| 123 | +ROOT_URLCONF = 'config.urls' |
| 124 | + |
| 125 | +TEMPLATES = [ |
| 126 | + { |
| 127 | + 'BACKEND': 'django.template.backends.django.DjangoTemplates', |
| 128 | + 'DIRS': [], |
| 129 | + 'APP_DIRS': True, |
| 130 | + 'OPTIONS': { |
| 131 | + 'context_processors': [ |
| 132 | + 'django.template.context_processors.debug', |
| 133 | + 'django.template.context_processors.request', |
| 134 | + 'django.contrib.auth.context_processors.auth', |
| 135 | + 'django.contrib.messages.context_processors.messages', |
| 136 | + ], |
| 137 | + }, |
| 138 | + }, |
| 139 | +] |
| 140 | + |
| 141 | +WSGI_APPLICATION = 'config.wsgi.application' |
| 142 | + |
| 143 | + |
106 | 144 | # Internationalization |
107 | 145 | # https://docs.djangoproject.com/en/2.0/topics/i18n/ |
108 | 146 |
|
|
116 | 154 |
|
117 | 155 | USE_TZ = True |
118 | 156 |
|
119 | | - |
120 | | -# Static files (CSS, JavaScript, Images) |
121 | | -# https://docs.djangoproject.com/en/2.0/howto/static-files/ |
122 | | - |
123 | | -STATIC_URL = '/static/' |
124 | | - |
125 | 157 | django_heroku.settings(locals()) |
0 commit comments