Skip to content

Commit

Permalink
Docker 环境参数判断
Browse files Browse the repository at this point in the history
  • Loading branch information
mtianyan committed Oct 9, 2020
1 parent 1595d88 commit 724ee85
Showing 1 changed file with 27 additions and 9 deletions.
36 changes: 27 additions & 9 deletions onlinemooc/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,34 @@
# Database
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'online_mooc', # 数据库名
'USER': 'root', # 用户名
'PASSWORD': 'mtianyanroot', # 密码
'HOST': '127.0.0.1', # 链接id ,空为本地,可以设置绝对路径
'PORT': '3306', # 端口号
try:
var = os.environ["not_use_docker"]
UseDocker = False
except KeyError:
UseDocker = True

if UseDocker:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'online_mooc', # 数据库名
'USER': 'root', # 用户名
'PASSWORD': 'mtianyanroot', # 密码
'HOST': 'mysql', # 链接id ,空为本地,可以设置绝对路径
'PORT': '3306', # 端口号
}
}
else:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'online_mooc', # 数据库名
'USER': 'root', # 用户名
'PASSWORD': 'mtianyanroot', # 密码
'HOST': '127.0.0.1', # 链接id ,空为本地,可以设置绝对路径
'PORT': '3306', # 端口号
}
}
}

# Password validation
# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
Expand Down

0 comments on commit 724ee85

Please sign in to comment.