Skip to content

Commit

Permalink
feat: add settings for simple (file) and difficult (posgresql) connec…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
Gray-Advantage committed Apr 10, 2024
1 parent 5689c8c commit 3f763d4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
9 changes: 8 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
DJANGO_DEBUG=False
DJANGO_SECRET_KEY=this_is_test_key_-_some_very_dummy_secret_key
DJANGO_ALLOWED_HOSTS=*

DJANGO_MAIL_HOST=smtp.mail.ru
DJANGO_MAIL_PORT=2525
DJANGO_MAIL_USER=webmaster@localhost
DJANGO_MAIL_PASSWORD=this_very_secret_password_for_smtp_mail
DEFAULT_USER_IS_ACTIVE=True

DJANGO_DEFAULT_USER_IS_ACTIVE=True

DJANGO_USE_SIMPLE_DATABASE=True
DJANGO_DATABASE_NAME=database
DJANGO_DATABASE_USER=webmaster
DJANGO_DATABASE_PASSWORD=this_very_secret_password_for_database
15 changes: 14 additions & 1 deletion datanar/datanar/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,19 @@
}


if not strtobool(config("DJANGO_USE_SIMPLE_DATABASE", "True")):
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql_psycopg2",
"NAME": config("DJANGO_DATABASE_NAME", cast=str),
"USER": config("DJANGO_DATABASE_USER", cast=str),
"PASSWORD": config("DJANGO_DATABASE_PASSWORD", cast=str),
"HOST": "localhost",
"PORT": "",
},
}


AUTH_PASSWORD_VALIDATORS = [
{
"NAME": (
Expand Down Expand Up @@ -131,7 +144,7 @@
AUTH_USER_MODEL = "users.User"

DEFAULT_USER_IS_ACTIVE = bool(
strtobool(config("DEFAULT_USER_IS_ACTIVE", "False")),
strtobool(config("DJANGO_DEFAULT_USER_IS_ACTIVE", "False")),
)

LOGIN_URL = "/auth/login/"
Expand Down

0 comments on commit 3f763d4

Please sign in to comment.