Skip to content

Commit

Permalink
🚜 Migrate to environs[django] (#68)
Browse files Browse the repository at this point in the history
* 🚜 Migrate to environs[django]

* ⚙️ Adds just bootstrap
  • Loading branch information
jefftriplett authored Oct 25, 2023
1 parent 52af4a6 commit 853d2f3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
3 changes: 3 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ set dotenv-load := true
# DEPENDENCIES #
##################

@bootstrap:
python -m pip install --editable '.[dev,hc,relay]'

install:
python -m pip install --editable '.[dev]'

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ hc = ["requests"]
lint = ["pre-commit"]
psycopg = ["psycopg[binary]"]
psycopg2 = ["psycopg2-binary"]
relay = ["dj-database-url"]
relay = ["environs[django]"]

[project.urls]
Documentation = "https://github.com/westerveltco/django-email-relay#readme"
Expand Down
8 changes: 5 additions & 3 deletions src/service/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import os
from typing import Any

import dj_database_url
import django
from django.conf import global_settings
from django.conf import settings
from django.core.management import call_command
from environs import Env

from email_relay.conf import EMAIL_RELAY_SETTINGS_NAME

Expand Down Expand Up @@ -133,9 +133,11 @@ def merge_with_defaults(
return return_dict


env = Env()

default_settings = {
"DATABASES": {
"default": dj_database_url.parse(os.getenv("DATABASE_URL", "sqlite://:memory:"))
"default": env.dj_db_url("DATABASE_URL", default="sqlite://:memory:")
},
"LOGGING": {
"version": 1,
Expand All @@ -147,7 +149,7 @@ def merge_with_defaults(
},
"root": {
"handlers": ["console"],
"level": os.getenv("LOG_LEVEL", "INFO"),
"level": env("LOG_LEVEL", "INFO"),
},
},
"INSTALLED_APPS": [
Expand Down

0 comments on commit 853d2f3

Please sign in to comment.