Skip to content

Commit

Permalink
Unified settings & made them easy to change on production
Browse files Browse the repository at this point in the history
  • Loading branch information
voron434 committed Feb 9, 2021
1 parent 14e0f21 commit 4d2a40f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
Доступны 3 переменные:
- `DEBUG` — дебаг-режим. Поставьте True, чтобы увидеть отладочную информацию в случае ошибки.
- `SECRET_KEY` — секретный ключ проекта
- `ALLOWED_HOSTS` — см [документацию Django](https://docs.djangoproject.com/en/3.1/ref/settings/#allowed-hosts).
- `DATABASE_NAME` — путь до базы данных, например: `schoolbase.sqlite3`

## Цели проекта
Expand Down
19 changes: 10 additions & 9 deletions project/settings.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import os

from dotenv import load_dotenv
load_dotenv()
from environs import Env

env = Env()
env.read_env()

ALLOWED_HOSTS = env.list("ALLOWED_HOSTS", [])

SECRET_KEY = env.str("SECRET_KEY", "REPLACE_ME")

DEBUG = env.bool("DEBUG", True)

DATABASES = {
'default': {
Expand All @@ -12,15 +20,8 @@

INSTALLED_APPS = ['datacenter']

SECRET_KEY = os.getenv("SECRET_KEY", "REPLACE_ME")

DEBUG = os.getenv("DEBUG", "true").lower() in ['yes', '1', 'true']

ROOT_URLCONF = "project.urls"

ALLOWED_HOSTS = ['*']


BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
TEMPLATES = [
{
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Django==2.2.3
pytz==2017.2
isoweek==1.3.*
python-dotenv==0.10.3
environs==5.2.1

0 comments on commit 4d2a40f

Please sign in to comment.