Externalize DEBUG, TIMEZONE, ALLOW_HOST and Add Install instruction in README.md

This commit is contained in:
sosokker 2023-09-05 21:44:19 +07:00
parent e0c7995f28
commit d61dd2ce4b
3 changed files with 19 additions and 6 deletions

View File

@ -28,6 +28,8 @@ or
**Don't forget to change `your_secret_key` to your secret key (without quote)**
**You can look at `sample.env` for more information and others environment variables to set.**
4. Run these commands
```bash
python manage.py migrate

View File

@ -11,7 +11,7 @@ https://docs.djangoproject.com/en/4.2/ref/settings/
"""
from pathlib import Path
from decouple import config
from decouple import config, Csv
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
@ -20,14 +20,15 @@ BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = config('SECRET_KEY', default='fake-secret-key')
#! SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = config('SECRET_KEY', default='k2pd1p)zwe0qy0k25=sli+7+n^vd-0h*&6vga6oldq=781+7qw')
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
#! SECURITY WARNING: don't run with debug turned on in production!
DEBUG = config('DEBUG', default=False, cast=bool)
ALLOWED_HOSTS = []
ALLOWED_HOSTS = config('ALLOWED_HOSTS', default='*', cast=Csv())
TIME_ZONE = config('TIME_ZONE', default='Asia/Bangkok', cast=str)
# Application definition

10
sample.env Normal file
View File

@ -0,0 +1,10 @@
# Copy this file to .env and edit the values
# Create a secret key using (todo: how to create a secret key?)
SECRET_KEY = secret-key-value-without-quotes
# Set DEBUG to True for development, False for actual use
DEBUG = False
# ALLOWED_HOSTS is a comma-separated list of hosts that can access the app.
# You can use wildcard chars (*) and IP addresses. Use * for any host.
ALLOWED_HOSTS = *.ku.th, localhost, 127.0.0.1, ::1
# Your timezone
TIME_ZONE = Asia/Bangkok