· 7 years ago · Apr 23, 2018, 01:08 AM
1athena/
2 |-- athena/
3 | |-- __init__.py
4 | |-- settings/
5 | | |-- __init__.py
6 | | |-- base.py <------
7 | |-- urls.py
8 | +-- wsgi.py
9 +-- manage.py
10
11import os
12
13from decouple import config
14
15# BASE_DIR = os.path.dirname(os.path.dirname(__file__))
16BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
17print ('-----------')
18
19# Quick-start development settings - unsuitable for production
20# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/
21
22# SECURITY WARNING: keep the secret key used in production secret!
23SECRET_KEY = config('SECRET_KEY')
24
25# SECURITY WARNING: don't run with debug turned on in production!
26DEBUG = config('DEBUG', cast=bool)
27
28ALLOWED_HOSTS = ['athe.herokuapp.com',
29 '127.0.0.1']
30
31TEMPLATES = [
32 {
33 'BACKEND': 'django.template.backends.django.DjangoTemplates',
34 'DIRS': [os.path.join(BASE_DIR, 'templates')],
35 'APP_DIRS': True,
36 'OPTIONS': {
37 'debug': DEBUG,
38 'context_processors': [
39 'django.template.context_processors.debug',
40 'django.template.context_processors.request',
41 'django.contrib.auth.context_processors.auth',
42 'django.contrib.messages.context_processors.messages',
43 ],
44 },
45 },
46]
47
48# Application definition
49
50INSTALLED_APPS = (
51 'athena_app.apps.AthenaAppConfig',
52 'django.contrib.admin',
53 'django.contrib.auth',
54 'django.contrib.contenttypes',
55 'django.contrib.sessions',
56 'django.contrib.messages',
57 'django.contrib.staticfiles',
58)
59
60MIDDLEWARE_CLASSES = (
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 'whitenoise.middleware.WhiteNoiseMiddleware',
69)
70
71ROOT_URLCONF = 'athena.urls'
72
73WSGI_APPLICATION = 'athena.wsgi.application'
74
75
76# Database
77# https://docs.djangoproject.com/en/1.7/ref/settings/#databases
78
79if os.environ['PROD_DB_NAME'] in os.environ():
80 print ('-----------------base')
81 DATABASES = {
82 'default': {
83 'ENGINE': 'django.db.backends.postgresql_psycopg2',
84 'NAME': config('PROD_DB_NAME'),
85 'USER': config('PROD_DB_USER'),
86 'PASSWORD': config('PROD_DB_PASSWORD'),
87 'HOST': config('PROD_DB_HOST'),
88 'PORT': config('PROD_DB_PORT')
89 }
90 }
91else:
92 print ('------------------BASE')
93 DATABASES = {
94 'default': {
95 'ENGINE': 'django.db.backends.postgresql_psycopg2',
96 'NAME': os.environ['DEV_DB_NAME'],
97 'USER': os.environ['DEV_DB_USERNAME'],
98 'PASSWORD': os.environ['DEV_DB_PASSWORD'],
99 'HOST': os.environ['DEV_DB_HOSTNAME'],
100 'PORT': os.environ['DEV_DB_PORT'],
101 }
102 }
103
104# Internationalization
105# https://docs.djangoproject.com/en/1.7/topics/i18n/
106
107LANGUAGE_CODE = 'en-us'
108
109TIME_ZONE = 'America/New_York'
110
111USE_I18N = True
112
113USE_L10N = True
114
115USE_TZ = False
116
117# Static files (CSS, JavaScript, Images)
118# https://docs.djangoproject.com/en/1.9/howto/static-files/
119# python athena/manage.py collectstatic --noinput
120
121# destination of collectstatic command
122STATIC_ROOT = 'https://athena-heroku.herokuapp.com/static/athena_app'
123# STATIC_ROOT = os.path.join(BASE_DIR, "athena_app/static/athena_app")
124STATIC_URL = '/static/'
125SITE_ROOT = os.path.dirname(os.path.realpath(__file__))
126STATICFILES_DIRS = (
127 os.path.join(BASE_DIR, 'athena_app/static/athena_app'),
128)
129STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
130
131LOGIN_URL = '/login'
132LOGOUT_REDIRECT_URL = '/home'
133
134Traceback (most recent call last):
135 File "manage.py", line 10, in <module>
136 execute_from_command_line(sys.argv)
137 File "/Users/robert.katz/ct-venv/ct-webapp/lib/python2.7/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
138 utility.execute()
139 File "/Users/robert.katz/ct-venv/ct-webapp/lib/python2.7/site-packages/django/core/management/__init__.py", line 307, in execute
140 settings.INSTALLED_APPS
141 File "/Users/robert.katz/ct-venv/ct-webapp/lib/python2.7/site-packages/django/conf/__init__.py", line 56, in __getattr__
142 self._setup(name)
143 File "/Users/robert.katz/ct-venv/ct-webapp/lib/python2.7/site-packages/django/conf/__init__.py", line 41, in _setup
144 self._wrapped = Settings(settings_module)
145 File "/Users/robert.katz/ct-venv/ct-webapp/lib/python2.7/site-packages/django/conf/__init__.py", line 110, in __init__
146 mod = importlib.import_module(self.SETTINGS_MODULE)
147 File "/Users/robert.katz/anaconda/lib/python2.7/importlib/__init__.py", line 37, in import_module
148 __import__(name)
149 File "/Users/robert.katz/other_projects/database/athena/athena/settings.py", line 96, in <module>
150 File "/Users/robert.katz/ct-venv/ct-webapp/lib/python2.7/UserDict.py", line 40, in __getitem__
151 raise KeyError(key)
152KeyError: 'DEV_DB_USERNAME'