fix logic bugs in settings
This commit is contained in:
parent
6a1cbcc862
commit
b4343227b1
|
@ -12,6 +12,9 @@ https://docs.djangoproject.com/en/2.1/ref/settings/
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
# Tell which environment
|
||||||
|
ENV = os.environ.get('ENV')
|
||||||
|
|
||||||
# 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__)))
|
||||||
|
|
||||||
|
@ -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$'
|
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!
|
# 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
|
# Application definition
|
||||||
|
|
||||||
|
@ -82,6 +85,15 @@ DATABASES = {
|
||||||
'ENGINE': 'django.db.backends.sqlite3',
|
'ENGINE': 'django.db.backends.sqlite3',
|
||||||
'NAME': os.path.join(BASE_DIR, 'db.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
|
# Password validation
|
||||||
|
@ -155,6 +167,14 @@ SESSION_COOKIE_HTTPONLY = False
|
||||||
APPEND_SLASH = True
|
APPEND_SLASH = True
|
||||||
|
|
||||||
# CELERY
|
# 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'
|
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
|
||||||
|
|
|
@ -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',
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -11,6 +11,6 @@ import os
|
||||||
|
|
||||||
from django.core.wsgi import get_wsgi_application
|
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()
|
application = get_wsgi_application()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user