· 9 years ago · Oct 11, 2016, 12:28 PM
1"""
2Django settings for mysite project.
3
4Generated by 'django-admin startproject' using Django 1.10.
5
6For more information on this file, see
7https://docs.djangoproject.com/en/1.10/topics/settings/
8
9For the full list of settings and their values, see
10https://docs.djangoproject.com/en/1.10/ref/settings/
11"""
12from django.core.exceptions import ImproperlyConfigured
13import os
14import time
15# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
16BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
17
18def get_env_variable(var_name):
19 try:
20 return os.environ[var_name]
21 except KeyError:
22 error_msg = "Set the %s environment variable" % var_name
23 raise ImproperlyConfigured(error_msg)
24# Quick-start development settings - unsuitable for production
25# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/
26
27# SECURITY WARNING: keep the secret key used in production secret!
28SECRET_KEY = '#lbsn&l-w+vrm=_(rv7yv_rgd6p$e0n^&p_h#+2)8agxi-98b)'
29
30# SECURITY WARNING: don't run with debug turned on in production!
31DEBUG = True
32
33ALLOWED_HOSTS = []
34
35
36# Application definition
37
38INSTALLED_APPS = [
39 'django.contrib.admin',
40 'django.contrib.auth',
41 'django.contrib.contenttypes',
42 'django.contrib.sessions',
43 'django.contrib.messages',
44 'django.contrib.staticfiles',
45 'umbrella',
46 'django.contrib.gis'
47]
48
49MIDDLEWARE = [
50 'django.middleware.security.SecurityMiddleware',
51 'django.contrib.sessions.middleware.SessionMiddleware',
52 'django.middleware.common.CommonMiddleware',
53 'django.middleware.csrf.CsrfViewMiddleware',
54 'django.contrib.auth.middleware.AuthenticationMiddleware',
55 'django.contrib.messages.middleware.MessageMiddleware',
56 'django.middleware.clickjacking.XFrameOptionsMiddleware',
57]
58
59ROOT_URLCONF = 'mysite.urls'
60
61TEMPLATES = [
62 {
63 'BACKEND': 'django.template.backends.django.DjangoTemplates',
64 'DIRS': [],
65 'APP_DIRS': True,
66 'OPTIONS': {
67 'context_processors': [
68 'django.template.context_processors.debug',
69 'django.template.context_processors.request',
70 'django.contrib.auth.context_processors.auth',
71 'django.contrib.messages.context_processors.messages',
72 ],
73 },
74 },
75]
76
77WSGI_APPLICATION = 'mysite.wsgi.application'
78
79
80# Database
81# https://docs.djangoproject.com/en/1.10/ref/settings/#databases
82
83
84# postgresql DATABASE setting
85# You might need to change your HOST under else. Don't change TRAVIS settings please
86if 'TRAVIS' in os.environ:
87 DATABASES = {
88 'default': {
89 'ENGINE': 'django.contrib.gis.db.backends.postgis',
90 'NAME': 'umbrella_db',
91 'USER': 'postgres',
92 'PASSWORD': '',
93 'HOST': 'localhost',
94 'PORT': '',
95 }
96 }
97else:
98 DATABASES = {
99 'default': {
100 'ENGINE': 'django.contrib.gis.db.backends.postgis',
101 'NAME': get_env_variable('DATABASE_NAME'),
102 'USER': get_env_variable('DATABASE_USER'),
103 'PASSWORD': get_env_variable('DATABASE_PASSWORD'),
104 'HOST': '',
105 'PORT': '',
106 }
107 }
108
109# Password validation
110# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators
111
112AUTH_PASSWORD_VALIDATORS = [
113 {
114 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
115 },
116 {
117 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
118 },
119 {
120 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
121 },
122 {
123 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
124 },
125]
126
127
128# Internationalization
129# https://docs.djangoproject.com/en/1.10/topics/i18n/
130
131LANGUAGE_CODE = 'en-us'
132
133
134def localTzname():
135 offsetHour = time.timezone / 3600
136 return 'Etc/GMT%+d' % offsetHour
137
138
139TIME_ZONE = localTzname()
140
141USE_I18N = True
142
143USE_L10N = True
144
145USE_TZ = True
146
147
148# Static files (CSS, JavaScript, Images)
149# https://docs.djangoproject.com/en/1.10/howto/static-files/
150
151STATIC_URL = '/static/'
152
153# Extra places for collect static to find static files
154STATICFILES_DIRS = [
155 os.path.join(BASE_DIR, "node_modules"), # Add node_modules folder
156 os.path.join(BASE_DIR, "staticfiles") # Add 'staticfiles' folder which contains static files such as css/js and images
157]