fix logic bugs in settings

This commit is contained in:
David 2019-05-08 20:01:25 +08:00
parent 6a1cbcc862
commit b4343227b1
3 changed files with 24 additions and 27 deletions

View File

@ -12,6 +12,9 @@ https://docs.djangoproject.com/en/2.1/ref/settings/
import os
# Tell which environment
ENV = os.environ.get('ENV')
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
@ -22,9 +25,9 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SECRET_KEY = 'l%o*o21h_a5^f+3xblzzfch*&2k_4pcak(o#t2@vymeb_mcy3$'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
DEBUG = ENV == 'DEV'
ALLOWED_HOSTS = []
ALLOWED_HOSTS = [] if DEBUG else ['127.0.0.1', 'localhost', 'code.wh.sdu.edu.cn']
# Application definition
@ -82,6 +85,15 @@ DATABASES = {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
} if DEBUG else {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'bookingservice',
'USER': 'postgres',
'PASSWORD': 'sduwhsduwh',
'HOST': '172.17.0.1',
'PORT': '5432',
}
}
# Password validation
@ -155,6 +167,14 @@ SESSION_COOKIE_HTTPONLY = False
APPEND_SLASH = True
# CELERY
CELERY_BROKER_URL = 'amqp://guest:guest@davidz.cn'
CELERY_BROKER_URL = 'amqp://guest:guest@davidz.cn' if DEBUG else 'amqp://guest:guest@172.17.0.1'
CELERY_TIMEZONE = 'Asia/Shanghai'
if not DEBUG:
SECURE_SSL_REDIRECT = True
# lower version of chrome and edge do not support same-site flag
SESSION_COOKIE_SAMESITE = None
CSRF_COOKIE_SAMESITE = None

View File

@ -1,23 +0,0 @@
from .settings import *
DEBUG = False
ALLOWED_HOSTS = ['127.0.0.1', 'localhost', 'code.wh.sdu.edu.cn']
SECURE_SSL_REDIRECT = True
# lower version of chrome and edge do not support same-site flag
SESSION_COOKIE_SAMESITE = None
CSRF_COOKIE_SAMESITE = None
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'bookingservice',
'USER': 'postgres',
'PASSWORD': 'sduwhsduwh',
'HOST': '172.17.0.1',
'PORT': '5432',
}
}

View File

@ -11,6 +11,6 @@ import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'BookingService.settings_production')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'BookingService.settings')
application = get_wsgi_application()