Skip to content

Commit

Permalink
use env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
zhabinka committed Jul 19, 2022
1 parent 268b64d commit ebaba67
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 17 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ __pycache__/
/db.sqlite3
media/
*.egg-info/
.env
.DS_Store
3 changes: 2 additions & 1 deletion djaif/middleware.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from django.contrib.auth import authenticate, login
from djaif.settings import SUPERUSER, PASSWORD


def auto_login(get_response):
def middleware(request): # noqa: WPS430

if not request.user.is_authenticated:
user = authenticate( # noqa: S106
username='admin', password='admin',
username=SUPERUSER, password=PASSWORD,
)
login(request, user)

Expand Down
23 changes: 8 additions & 15 deletions djaif/settings.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
"""
Django settings for djaif project.
Generated by 'django-admin startproject' using Django 3.0.5.
For more information on this file, see
https://docs.djangoproject.com/en/3.0/topics/settings/
import os
from dotenv import load_dotenv

For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.0/ref/settings/
"""

import os
load_dotenv()

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
Expand All @@ -19,11 +11,12 @@
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'wpw=^28n)_)+ho#&z$5u12z50ny$3f%+8ld#)q2^a+87e_$o1o'
DJANGO_SETTINGS_MODULE = 'djaif.settings'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
SECRET_KEY = os.getenv('SECRET_KEY')
DEBUG = os.getenv('DEBUG', 'False') == 'True'
SUPERUSER = os.getenv('SUPERUSER', 'admin')
PASSWORD = os.getenv('PASSWORD', 'admin')

ALLOWED_HOSTS = []

Expand Down
14 changes: 13 additions & 1 deletion poetry.lock

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

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ django = "^4.0.6"
Pillow = "^9.2.0"
graphviz = "^0.20"
django-extensions = "^3.2.0"
python-dotenv = "^0.20.0"

[tool.poetry.dev-dependencies]
wemake-python-styleguide = "^0.14.0"
Expand Down

0 comments on commit ebaba67

Please sign in to comment.