pipenv install python-decouple dj-database-url
- 建立
.env
- 修改
settings.py
-
-
Save wastemobile/2e5fa7d58eadfeac926a9295c3fdf7a9 to your computer and use it in GitHub Desktop.
Django settings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# dev | |
SECRET_KEY=4(hf^my1$a*dwf^78^x0zl-z)*)p&)40z#o307o*)p_x2ker^v | |
DEBUG=True | |
ALLOWED_HOSTS=.localhost,127.0.0.1 | |
# for PostgreSQL | |
# DATABASE_URL=postgres://dba:password@localhost:5432/db | |
# for Gmail | |
# EMAIL_BACKEND="django.core.mail.backends.console.EmailBackend" | |
# EMAIL_HOST="smtp.gmail.com" | |
# EMAIL_PORT="587" | |
# EMAIL_USE_TLS=True | |
# EMAIL_USER="[email protected]" | |
# EMAIL_PASS="app-password" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from decouple import config, Csv | |
from dj_database_url import parse as db_url | |
SECRET_KEY = config('SECRET_KEY') | |
DEBUG = config('DEBUG', default=False, cast=bool) | |
ALLOWED_HOSTS = config('ALLOWED_HOSTS', cast=Csv()) | |
DATABASES = { | |
'default': config( | |
'DATABASE_URL', | |
default='sqlite:///' + os.path.join(BASE_DIR, 'db.sqlite3'), | |
cast=db_url | |
) | |
} | |
LANGUAGE_CODE = 'zh-Hant' | |
TIME_ZONE = 'Asia/Taipei' | |
STATIC_URL = '/static/' | |
STATIC_ROOT = os.path.join(BASE_DIR, 'static') | |
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'asset')] | |
EMAIL_BACKEND = config('EMAIL_BACKEND', default='django.core.mail.backends.smtp.EmailBackend') | |
EMAIL_HOST = config('EMAIL_HOST', default='localhost') | |
EMAIL_PORT = config('EMAIL_PORT', default=25, cast=int) | |
EMAIL_HOST_PASSWORD = config('EMAIL_HOST_PASSWORD', default='') | |
EMAIL_HOST_USER = config('EMAIL_HOST_USER', default='') | |
EMAIL_USE_TLS = config('EMAIL_USE_TLS', default=False, cast=bool) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment