Skip to content

Commit

Permalink
feat: integrate database (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
moonlitgrace authored Nov 8, 2024
1 parent f1b5743 commit 51321c3
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 9 deletions.
6 changes: 6 additions & 0 deletions backend/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Django Settings
DEBUG=1
SECRET_KEY='ilovequibble'

# Postgres DB
DATABASE_URL='postgres://postgres:quibble_pass@localhost:5432/quibble_db'
24 changes: 16 additions & 8 deletions backend/backend/core/settings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""
'''
Django settings for core project.
Generated by 'django-admin startproject' using Django 5.1.3.
Expand All @@ -8,9 +8,16 @@
For the full list of settings and their values, see
https://docs.djangoproject.com/en/5.1/ref/settings/
"""
'''

import os
import dj_database_url

from pathlib import Path
from dotenv import load_dotenv

# monkeypatch envs
load_dotenv()

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
Expand All @@ -20,10 +27,10 @@
# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-^e0g9rxsvgj@b_8hd@#me!pe@$*tmo6&dcxyjf42@iz#v)r!#9'
SECRET_KEY = os.getenv('SECRET_KEY', 'ilovequibble')

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
DEBUG = bool(os.getenv('DEBUG', 1))

ALLOWED_HOSTS = []

Expand Down Expand Up @@ -74,10 +81,11 @@
# https://docs.djangoproject.com/en/5.1/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
'default': dj_database_url.config(
default=os.getenv('DATABASE_URL'),
conn_max_age=600,
conn_health_checks=True,
),
}


Expand Down
107 changes: 106 additions & 1 deletion backend/poetry.lock

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

3 changes: 3 additions & 0 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ python = "^3.12"
django = "^5.1.3"
django-types = "^0.19.1"
django-stubs-ext = "^5.1.1"
psycopg2-binary = "^2.9.10"
dj-database-url = "^2.3.0"
python-dotenv = "^1.0.1"

[tool.pyright]
venvPath = "./"
Expand Down

0 comments on commit 51321c3

Please sign in to comment.