Skip to content

Commit

Permalink
add environ variables, env.example (#16)
Browse files Browse the repository at this point in the history
Co-authored-by: Mitsushidu <[email protected]>
  • Loading branch information
Mitsushidu and Mitsushidu authored May 2, 2024
1 parent 7f92cb4 commit 9071de7
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 15 deletions.
20 changes: 20 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Название, логин и пароль для БД postgres
POSTGRES_DB=postgres_db
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres

# Данные для подключения к БД
DB_HOST=db
DB_PORT=5432

# Переменные Django
# ПРЕДУПРЕЖДЕНИЕ: Хранить секретный ключ не должен попадать в общий доступ
SECRET_KEY=secret_key
# ПРЕДУПРЕЖДЕНИЕ: Debug = true использовать только при разработке
DEBUG=True
# Список разрешенных хостов
ALLOWED_HOSTS='localhost 127.0.0.1'

# Переменные бота
# Токен для подключения к Telegram API
TELEGRAM_TOKEN=token
36 changes: 26 additions & 10 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ python = "^3.12"
django = "^5.0.4"
python-telegram-bot = "^21.1.1"
poetry-plugin-export = "^1.7.1"
django-environ= "^0.11.2"
django-asgi-lifespan = "^0.3.1"


[tool.poetry.group.dev.dependencies]
ruff = "^0.4.2"

Expand Down
17 changes: 13 additions & 4 deletions src/core/settings.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
import os
from pathlib import Path

import environ

env = environ.Env(
DEBUG=(bool, False)
)

BASE_DIR = Path(__file__).resolve().parent.parent

SECRET_KEY = "django-insecure-v3b$$**=s5=icl9=sn%p^8o3332r(ams5)vgpv+#ssmep*pq=1"
environ.Env.read_env(os.path.join(BASE_DIR, '.env'))

SECRET_KEY = env('SECRET_KEY')

DEBUG = True
DEBUG = env('DEBUG')

ALLOWED_HOSTS = []
ALLOWED_HOSTS = env('ALLOWED_HOSTS').split()

INSTALLED_APPS = [
"django.contrib.admin",
Expand Down Expand Up @@ -82,4 +91,4 @@

DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"

TELEGRAM_TOKEN = 'нужно импортировать из environ'
TELEGRAM_TOKEN = env('TELEGRAM_TOKEN')

0 comments on commit 9071de7

Please sign in to comment.