Skip to content

Commit

Permalink
支持通过环境变量设置 ALLOWED_HOSTS
Browse files Browse the repository at this point in the history
  • Loading branch information
yangxg committed Sep 19, 2019
1 parent 3b71c37 commit 13de046
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -98,4 +98,5 @@ media/
node_modules/
!frontend/dist
/static/
_credentials.py
_credentials.py
.envs/
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -30,6 +30,8 @@
SECRET_KEY=your-own-secret-key
DJANGO_SETTINGS_MODULE=config.settings.production
DJANGO_SENDGRID_API_KEY=your-own-sendgrid-api-key
# 设置允许访问的 HOSTS,逗号分隔
DJANGO_ALLOWED_HOSTS=your-domain.com,www.yourdomain.com
```

`SECRET_KEY`:项目密钥,推荐使用 [Django Secret Key Generator](https://www.miniwebtool.com/django-secret-key-generator/) 自动生成。
Expand Down
2 changes: 1 addition & 1 deletion config/settings/production.py
Expand Up @@ -4,7 +4,7 @@

SECRET_KEY = env('SECRET_KEY')

ALLOWED_HOSTS = ['.zmrenwu.com']
ALLOWED_HOSTS = env.list("DJANGO_ALLOWED_HOSTS")

DEBUG = False

Expand Down

0 comments on commit 13de046

Please sign in to comment.