Update Django/platform settings

This commit is contained in:
Livvy Mackintosh 2017-05-21 01:54:52 +02:00
parent f2636e8340
commit 8ec2344f68

View File

@ -11,6 +11,7 @@ https://docs.djangoproject.com/en/1.11/ref/settings/
""" """
import os import os
from django.utils.translation import ugettext_lazy as _
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
@ -20,7 +21,10 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/ # See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret! # SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'r3vwfrawmnwh3kzp4(p#sg0!y%!jg80k06(j@p!y(q^h@5y*lw' SECRET_KEY = os.getenv(
'SECRET_KEY',
'r3vwfrawmnwh3kzp4(p#sg0!y%!jg80k06(j@p!y(q^h@5y*lw'
)
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = bool(int(os.getenv('DEBUG', False))) DEBUG = bool(int(os.getenv('DEBUG', False)))
@ -31,7 +35,7 @@ ALLOWED_HOSTS = os.getenv('ALLOWED_HOSTS', 'localhost').split()
# Application definition # Application definition
INSTALLED_APPS = [ INSTALLED_APPS = [
'ojusomap.apps.map', 'apps.map',
'django.contrib.admin', 'django.contrib.admin',
'django.contrib.auth', 'django.contrib.auth',
'django.contrib.contenttypes', 'django.contrib.contenttypes',
@ -39,11 +43,14 @@ INSTALLED_APPS = [
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'django.contrib.gis', 'django.contrib.gis',
'crispy_forms',
'leaflet',
] ]
MIDDLEWARE = [ MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware', 'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware', 'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware', 'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware',
@ -82,11 +89,11 @@ ADMINS = [('Livvy Mackintosh', 'livvy@base.nu')]
DATABASES = { DATABASES = {
'default': { 'default': {
'ENGINE': 'django.contrib.gis.db.backends.postgis', 'ENGINE': 'django.contrib.gis.db.backends.postgis',
'HOST': os.getenv('DATABASE_HOST','localhost'), 'HOST': os.getenv('DATABASE_HOST', 'localhost'),
'PORT': os.getenv('DATABASE_PORT', '5432'), 'PORT': os.getenv('DATABASE_PORT', '5432'),
'NAME': os.getenv('DATABASE_NAME', 'postgres'), 'NAME': os.getenv('DATABASE_NAME', 'postgres'),
'USER': os.getenv('DATABASE_USER', 'postgres'), 'USER': os.getenv('DATABASE_USER', 'postgres'),
'PASSWORD': os.getenv('DATABASE_PASSWORD','postgres'), 'PASSWORD': os.getenv('DATABASE_PASSWORD', 'postgres'),
} }
} }
@ -95,16 +102,20 @@ DATABASES = {
AUTH_PASSWORD_VALIDATORS = [ AUTH_PASSWORD_VALIDATORS = [
{ {
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 'NAME': 'django.contrib.auth.password_validation.\
UserAttributeSimilarityValidator',
}, },
{ {
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 'NAME': 'django.contrib.auth.password_validation.\
MinimumLengthValidator',
}, },
{ {
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 'NAME': 'django.contrib.auth.password_validation.\
CommonPasswordValidator',
}, },
{ {
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 'NAME': 'django.contrib.auth.password_validation.\
NumericPasswordValidator',
}, },
] ]
@ -122,9 +133,34 @@ USE_L10N = True
USE_TZ = True USE_TZ = True
LANGUAGES = [
('en', _('English')),
('es', _('Spanish')),
]
LOCALE_PATHS = [
os.path.join(BASE_DIR, 'support/locales')
]
# Static files (CSS, JavaScript, Images) # Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/ # https://docs.djangoproject.com/en/1.11/howto/static-files/
STATIC_ROOT = os.path.join(BASE_DIR, 'static/') STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
STATIC_URL = os.getenv("STATIC_URL",'/static/') STATIC_URL = os.getenv("STATIC_URL", '/static/')
# Cache
# https://docs.djangoproject.com/en/1.11/topics/cache/
if not DEBUG:
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': 'cache:11211',
}
}
else:
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
}
}