Dirk Vogt | f130c75 | 2016-08-23 14:45:01 +0200 | [diff] [blame] | 1 | """ |
| 2 | Django settings for hiccup_server project. |
| 3 | |
| 4 | Generated by 'django-admin startproject' using Django 1.9.7. |
| 5 | |
| 6 | For more information on this file, see |
| 7 | https://docs.djangoproject.com/en/1.9/topics/settings/ |
| 8 | |
| 9 | For the full list of settings and their values, see |
| 10 | https://docs.djangoproject.com/en/1.9/ref/settings/ |
| 11 | """ |
| 12 | |
| 13 | import os |
| 14 | |
| 15 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...) |
| 16 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
| 17 | |
| 18 | |
| 19 | # Quick-start development settings - unsuitable for production |
| 20 | # See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/ |
| 21 | |
| 22 | # SECURITY WARNING: keep the secret key used in production secret! |
| 23 | SECRET_KEY = '7u+#ha3hk!x+*)clhs46%n*)w1q+5s4+yoc#1!nm0b%fwwrud@' |
| 24 | |
| 25 | # SECURITY WARNING: don't run with debug turned on in production! |
Dirk Vogt | f2a3342 | 2016-10-11 17:17:26 +0200 | [diff] [blame] | 26 | DEBUG = True |
Dirk Vogt | f130c75 | 2016-08-23 14:45:01 +0200 | [diff] [blame] | 27 | |
Dirk Vogt | 20539e5 | 2016-08-26 11:17:35 +0200 | [diff] [blame] | 28 | ALLOWED_HOSTS = ['*'] |
Dirk Vogt | f130c75 | 2016-08-23 14:45:01 +0200 | [diff] [blame] | 29 | |
| 30 | |
| 31 | # Application definition |
| 32 | |
| 33 | INSTALLED_APPS = [ |
| 34 | 'django.contrib.admin', |
| 35 | 'django.contrib.auth', |
| 36 | 'django.contrib.contenttypes', |
| 37 | 'django.contrib.sessions', |
Dirk Vogt | 57a615d | 2017-05-04 22:29:54 +0200 | [diff] [blame] | 38 | 'django.contrib.sites', |
Dirk Vogt | f130c75 | 2016-08-23 14:45:01 +0200 | [diff] [blame] | 39 | 'django.contrib.messages', |
| 40 | 'django.contrib.staticfiles', |
Dirk Vogt | 47d80ba | 2016-08-26 09:31:39 +0200 | [diff] [blame] | 41 | 'rest_framework', |
Dirk Vogt | f2a3342 | 2016-10-11 17:17:26 +0200 | [diff] [blame] | 42 | 'rest_framework.authtoken', |
Dirk Vogt | f130c75 | 2016-08-23 14:45:01 +0200 | [diff] [blame] | 43 | 'crashreports', |
Dirk Vogt | 62ff7f2 | 2017-05-04 16:07:21 +0200 | [diff] [blame] | 44 | 'crashreport_stats', |
Dirk Vogt | f2a3342 | 2016-10-11 17:17:26 +0200 | [diff] [blame] | 45 | 'taggit', |
Dirk Vogt | d134521 | 2016-09-14 14:31:45 +0200 | [diff] [blame] | 46 | 'crispy_forms', |
Dirk Vogt | f5a1553 | 2016-09-26 15:52:24 +0200 | [diff] [blame] | 47 | 'bootstrap3', |
Dirk Vogt | 57a615d | 2017-05-04 22:29:54 +0200 | [diff] [blame] | 48 | 'bootstrapform', |
Dirk Vogt | f2a3342 | 2016-10-11 17:17:26 +0200 | [diff] [blame] | 49 | 'django_extensions', |
Mitja Nikolaus | 5c3e057 | 2018-07-30 13:36:14 +0200 | [diff] [blame^] | 50 | 'django_filters', |
Dirk Vogt | 62ff7f2 | 2017-05-04 16:07:21 +0200 | [diff] [blame] | 51 | 'djfrontend', |
Dirk Vogt | 57a615d | 2017-05-04 22:29:54 +0200 | [diff] [blame] | 52 | 'djfrontend.skeleton', |
| 53 | 'allauth', |
| 54 | 'allauth.account', |
| 55 | 'allauth.socialaccount', |
| 56 | 'allauth.socialaccount.providers.google', |
Dirk Vogt | f130c75 | 2016-08-23 14:45:01 +0200 | [diff] [blame] | 57 | ] |
| 58 | |
| 59 | MIDDLEWARE_CLASSES = [ |
| 60 | 'django.middleware.security.SecurityMiddleware', |
| 61 | 'django.contrib.sessions.middleware.SessionMiddleware', |
| 62 | 'django.middleware.common.CommonMiddleware', |
| 63 | 'django.middleware.csrf.CsrfViewMiddleware', |
| 64 | 'django.contrib.auth.middleware.AuthenticationMiddleware', |
| 65 | 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', |
| 66 | 'django.contrib.messages.middleware.MessageMiddleware', |
| 67 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', |
| 68 | ] |
| 69 | |
| 70 | ROOT_URLCONF = 'hiccup.urls' |
| 71 | |
Dirk Vogt | 57a615d | 2017-05-04 22:29:54 +0200 | [diff] [blame] | 72 | TEMPLATE_LOADERS = ( |
| 73 | 'django.template.loaders.filesystem.Loader', |
| 74 | 'django.template.loaders.app_directories.Loader', |
Dirk Vogt | 57a615d | 2017-05-04 22:29:54 +0200 | [diff] [blame] | 75 | ) |
| 76 | |
Dirk Vogt | f130c75 | 2016-08-23 14:45:01 +0200 | [diff] [blame] | 77 | TEMPLATES = [ |
| 78 | { |
| 79 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', |
Mitja Nikolaus | 5c3e057 | 2018-07-30 13:36:14 +0200 | [diff] [blame^] | 80 | 'DIRS': [os.path.join(BASE_DIR, 'hiccup', 'templates')], |
Dirk Vogt | f130c75 | 2016-08-23 14:45:01 +0200 | [diff] [blame] | 81 | 'APP_DIRS': True, |
| 82 | 'OPTIONS': { |
| 83 | 'context_processors': [ |
| 84 | 'django.template.context_processors.debug', |
| 85 | 'django.template.context_processors.request', |
| 86 | 'django.contrib.auth.context_processors.auth', |
| 87 | 'django.contrib.messages.context_processors.messages', |
Dirk Vogt | 57a615d | 2017-05-04 22:29:54 +0200 | [diff] [blame] | 88 | # `allauth` needs this from django |
| 89 | 'django.template.context_processors.request', |
Dirk Vogt | f130c75 | 2016-08-23 14:45:01 +0200 | [diff] [blame] | 90 | ], |
| 91 | }, |
| 92 | }, |
| 93 | ] |
| 94 | |
Dirk Vogt | 57a615d | 2017-05-04 22:29:54 +0200 | [diff] [blame] | 95 | AUTHENTICATION_BACKENDS = ( |
| 96 | # Needed to login by username in Django admin, regardless of `allauth` |
| 97 | 'django.contrib.auth.backends.ModelBackend', |
| 98 | |
| 99 | # `allauth` specific authentication methods, such as login by e-mail |
| 100 | 'allauth.account.auth_backends.AuthenticationBackend', |
| 101 | ) |
| 102 | |
Mitja Nikolaus | 5c3e057 | 2018-07-30 13:36:14 +0200 | [diff] [blame^] | 103 | # WSGI_APPLICATION = 'hiccup_server.wsgi.application' |
Dirk Vogt | f130c75 | 2016-08-23 14:45:01 +0200 | [diff] [blame] | 104 | |
| 105 | |
| 106 | # Database |
| 107 | # https://docs.djangoproject.com/en/1.9/ref/settings/#databases |
| 108 | |
| 109 | DATABASES = { |
| 110 | 'default': { |
| 111 | 'ENGINE': 'django.db.backends.sqlite3', |
| 112 | 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | |
| 117 | # Password validation |
| 118 | # https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators |
| 119 | |
| 120 | AUTH_PASSWORD_VALIDATORS = [ |
| 121 | { |
Mitja Nikolaus | 5c3e057 | 2018-07-30 13:36:14 +0200 | [diff] [blame^] | 122 | 'NAME': 'django.contrib.auth.password_validation' |
| 123 | '.UserAttributeSimilarityValidator', |
Dirk Vogt | f130c75 | 2016-08-23 14:45:01 +0200 | [diff] [blame] | 124 | }, |
| 125 | { |
Mitja Nikolaus | 5c3e057 | 2018-07-30 13:36:14 +0200 | [diff] [blame^] | 126 | 'NAME': 'django.contrib.auth.password_validation' |
| 127 | '.MinimumLengthValidator', |
Dirk Vogt | f130c75 | 2016-08-23 14:45:01 +0200 | [diff] [blame] | 128 | }, |
| 129 | { |
Mitja Nikolaus | 5c3e057 | 2018-07-30 13:36:14 +0200 | [diff] [blame^] | 130 | 'NAME': 'django.contrib.auth.password_validation' |
| 131 | '.CommonPasswordValidator', |
Dirk Vogt | f130c75 | 2016-08-23 14:45:01 +0200 | [diff] [blame] | 132 | }, |
| 133 | { |
Mitja Nikolaus | 5c3e057 | 2018-07-30 13:36:14 +0200 | [diff] [blame^] | 134 | 'NAME': 'django.contrib.auth.password_validation' |
| 135 | '.NumericPasswordValidator', |
Dirk Vogt | f130c75 | 2016-08-23 14:45:01 +0200 | [diff] [blame] | 136 | }, |
| 137 | ] |
| 138 | |
Dirk Vogt | f130c75 | 2016-08-23 14:45:01 +0200 | [diff] [blame] | 139 | # Internationalization |
| 140 | # https://docs.djangoproject.com/en/1.9/topics/i18n/ |
| 141 | |
| 142 | LANGUAGE_CODE = 'en-us' |
| 143 | TIME_ZONE = 'Europe/Amsterdam' |
| 144 | USE_I18N = True |
| 145 | USE_L10N = True |
| 146 | USE_TZ = True |
| 147 | |
Dirk Vogt | 47d80ba | 2016-08-26 09:31:39 +0200 | [diff] [blame] | 148 | REST_FRAMEWORK = { |
Dirk Vogt | f2a3342 | 2016-10-11 17:17:26 +0200 | [diff] [blame] | 149 | 'DEFAULT_AUTHENTICATION_CLASSES': ( |
| 150 | 'rest_framework.authentication.BasicAuthentication', |
| 151 | 'rest_framework.authentication.SessionAuthentication', |
| 152 | 'rest_framework.authentication.TokenAuthentication', |
| 153 | ), |
Dirk Vogt | 47d80ba | 2016-08-26 09:31:39 +0200 | [diff] [blame] | 154 | 'DEFAULT_PERMISSION_CLASSES': ( |
| 155 | 'rest_framework.permissions.IsAuthenticated', |
Dirk Vogt | d134521 | 2016-09-14 14:31:45 +0200 | [diff] [blame] | 156 | ), |
Mitja Nikolaus | 5c3e057 | 2018-07-30 13:36:14 +0200 | [diff] [blame^] | 157 | 'DEFAULT_FILTER_BACKENDS': |
| 158 | ('django_filters.rest_framework.DjangoFilterBackend',), |
| 159 | 'DEFAULT_PAGINATION_CLASS': |
| 160 | 'rest_framework.pagination.LimitOffsetPagination', |
Dirk Vogt | 57a615d | 2017-05-04 22:29:54 +0200 | [diff] [blame] | 161 | 'PAGE_SIZE': 100 |
| 162 | } |
| 163 | |
| 164 | SITE_ID = 1 |
| 165 | |
Mitja Nikolaus | 5c3e057 | 2018-07-30 13:36:14 +0200 | [diff] [blame^] | 166 | SOCIALACCOUNT_ADAPTER = "hiccup.allauth_adapters.FairphoneAccountAdapter" |
| 167 | LOGIN_REDIRECT_URL = "/hiccup_stats/" |
Dirk Vogt | 57a615d | 2017-05-04 22:29:54 +0200 | [diff] [blame] | 168 | # disable form signups |
Mitja Nikolaus | 5c3e057 | 2018-07-30 13:36:14 +0200 | [diff] [blame^] | 169 | ACCOUNT_ADAPTER = "hiccup.allauth_adapters.FormAccountAdapter" |
| 170 | ACCOUNT_EMAIL_REQUIRED = True |
| 171 | ACCOUNT_LOGOUT_REDIRECT_URL = "/accounts/login/" |
Dirk Vogt | 57a615d | 2017-05-04 22:29:54 +0200 | [diff] [blame] | 172 | |
| 173 | SOCIALACCOUNT_PROVIDERS = { |
| 174 | 'google': { |
| 175 | 'SCOPE': [ |
| 176 | 'profile', |
| 177 | 'email', |
| 178 | ], |
| 179 | 'AUTH_PARAMS': { |
| 180 | 'access_type': 'online', |
| 181 | } |
| 182 | } |
Dirk Vogt | 47d80ba | 2016-08-26 09:31:39 +0200 | [diff] [blame] | 183 | } |
| 184 | |
Dirk Vogt | f130c75 | 2016-08-23 14:45:01 +0200 | [diff] [blame] | 185 | # Static files (CSS, JavaScript, Images) |
| 186 | # https://docs.djangoproject.com/en/1.9/howto/static-files/ |
| 187 | |
| 188 | STATIC_URL = '/static/' |
Dirk Vogt | 20539e5 | 2016-08-26 11:17:35 +0200 | [diff] [blame] | 189 | |
Mitja Nikolaus | c6c2ef9 | 2018-07-20 10:02:18 +0200 | [diff] [blame] | 190 | STATIC_ROOT = os.path.join(BASE_DIR, 'static') |
Dirk Vogt | d8b956b | 2016-11-22 15:03:21 +0100 | [diff] [blame] | 191 | |
Franz-Xaver Geiger | 69909c9 | 2018-02-27 17:02:38 +0100 | [diff] [blame] | 192 | |
| 193 | # Logging |
| 194 | # https://docs.djangoproject.com/en/2.0/topics/logging/#examples |
| 195 | |
| 196 | LOGGING = { |
| 197 | 'version': 1, |
| 198 | 'disable_existing_loggers': False, |
| 199 | 'handlers': { |
| 200 | 'file': { |
| 201 | 'level': 'DEBUG', |
| 202 | 'class': 'logging.FileHandler', |
Mitja Nikolaus | c6c2ef9 | 2018-07-20 10:02:18 +0200 | [diff] [blame] | 203 | 'filename': os.path.join(BASE_DIR, 'debug.log'), |
Franz-Xaver Geiger | 69909c9 | 2018-02-27 17:02:38 +0100 | [diff] [blame] | 204 | }, |
| 205 | }, |
| 206 | 'loggers': { |
| 207 | 'django': { |
| 208 | 'handlers': ['file'], |
| 209 | 'level': 'DEBUG', |
| 210 | 'propagate': True, |
| 211 | }, |
| 212 | }, |
| 213 | } |
| 214 | |
Dirk Vogt | d8b956b | 2016-11-22 15:03:21 +0100 | [diff] [blame] | 215 | try: |
Mitja Nikolaus | 5c3e057 | 2018-07-30 13:36:14 +0200 | [diff] [blame^] | 216 | from local_settings import * # noqa: F403, F401 |
Dirk Vogt | d8b956b | 2016-11-22 15:03:21 +0100 | [diff] [blame] | 217 | except ImportError as e: |
| 218 | pass |