make settings, env settings, and requirements less complex

This commit is contained in:
Thomas Steen Rasmussen 2016-11-22 21:04:06 +01:00
parent 6ca19b6358
commit 820000ca83
11 changed files with 53 additions and 66 deletions

View file

@ -1,6 +1,7 @@
### set database url and allowed_hosts here
DATABASE_URL=postgres://username:password@host:port/database
ALLOWED_HOSTS=localhost,127.0.0.1
DEBUG=True
### changes below here are only needed for production
SECRET_KEY=somethingverysecretandunique

View file

@ -48,6 +48,42 @@ INSTALLED_APPS = [
'bootstrap3',
]
DEBUG = env('DEBUG')
if DEBUG:
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
INSTALLED_APPS += ['debug_toolbar', ]
else:
EMAIL_HOST = env('EMAIL_HOST')
EMAIL_PORT = env('EMAIL_PORT')
EMAIL_HOST_USER = env('EMAIL_HOST_USER')
EMAIL_HOST_PASSWORD = env('EMAIL_HOST_PASSWORD')
EMAIL_USE_TLS = env('EMAIL_USE_TLS')
DEFAULT_FROM_EMAIL = env('DEFAULT_FROM_EMAIL')
SERVER_EMAIL = env('DEFAULT_FROM_EMAIL')
ARCHIVE_EMAIL = env('ARCHIVE_EMAIL')
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'mail_admins': {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler',
},
'console': {
'level':'DEBUG',
'class':'logging.StreamHandler',
},
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}
STATIC_URL = '/static/'
STATIC_ROOT = local_dir('static')
STATICFILES_DIRS = [local_dir('static_src')]

View file

@ -1,11 +0,0 @@
from .base import *
import environ
env = environ.Env()
environ.Env.read_env()
DEBUG = True
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
# INSTALLED_APPS += ['debug_toolbar', ]

View file

@ -1,38 +0,0 @@
from .base import *
import environ
env = environ.Env()
environ.Env.read_env()
DEBUG = False
EMAIL_HOST = env('EMAIL_HOST')
EMAIL_PORT = env('EMAIL_PORT')
EMAIL_HOST_USER = env('EMAIL_HOST_USER')
EMAIL_HOST_PASSWORD = env('EMAIL_HOST_PASSWORD')
EMAIL_USE_TLS = env('EMAIL_USE_TLS')
DEFAULT_FROM_EMAIL = env('DEFAULT_FROM_EMAIL')
SERVER_EMAIL = env('DEFAULT_FROM_EMAIL')
ARCHIVE_EMAIL = env('ARCHIVE_EMAIL')
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'mail_admins': {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler',
},
'console': {
'level':'DEBUG',
'class':'logging.StreamHandler',
},
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}

View file

@ -11,6 +11,6 @@ import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "bornhack.settings.production")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "bornhack.settings")
application = get_wsgi_application()

View file

@ -5,7 +5,7 @@ import sys
if __name__ == "__main__":
os.environ.setdefault(
"DJANGO_SETTINGS_MODULE",
"bornhack.settings.production"
"bornhack.settings"
)
from django.core.management import execute_from_command_line

14
requirements.txt Normal file
View file

@ -0,0 +1,14 @@
django>=1.10
django-allauth>=0.29.0
django-bootstrap3>=7.0.1
django-environ>=0.4.1
psycopg2>=2.6.2
PyPDF2>=1.26
django-wkhtmltopdf>=3.1.0
Pillow==3.2.0
qrcode==5.3
CommonMark==0.7.2
django-bleach==0.3.0
Unidecode==0.4.19
django-debug-toolbar>=1.6

View file

@ -1,12 +0,0 @@
django>=1.9
django-allauth>=0.23.0
django-bootstrap3>=7.0.0
django-environ>=0.4.0
psycopg2>=2.6.1
PyPDF2>=1.25.1
django-wkhtmltopdf>=3.0.0
Pillow==3.2.0
qrcode==5.3
CommonMark==0.6.4
django-bleach==0.3.0
Unidecode==0.4.19

View file

@ -1,2 +0,0 @@
-r base.txt
django-debug-toolbar==1.3.2

View file

@ -1 +0,0 @@
-r base.txt