Initial settings configuration.

pull/1/head
Calum Andrew Morrell 2025-02-16 21:55:49 +00:00
parent 557dc279c7
commit e7148362f0
4 changed files with 91 additions and 16 deletions

16
.env-template Normal file
View File

@ -0,0 +1,16 @@
DJANGO_SECRET_KEY=''
DEBUG='True'
ALLOWED_HOSTS=[]
DB_NAME=''
DB_USER=''
DB_PASSWORD=''
DB_HOST='localhost'
DB_PORT=5432
EMAIL_HOST=''
EMAIL_PORT=
EMAIL_USE_TLS='True'
EMAIL_HOST_USER=''
EMAIL_HOST_PASSWORD=''

View File

@ -9,24 +9,26 @@ https://docs.djangoproject.com/en/5.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/5.1/ref/settings/
"""
import os
from pathlib import Path
from dotenv import load_dotenv
load_dotenv()
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# 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-e7m1a6dwy1^-^zp^*_(ql^c8y5!^0$kf4jwarw^3ny5b(d^t1r'
SECRET_KEY = os.getenv('DJANGO_SECRET_KEY')
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
DEBUG = os.getenv('DEBUG')
ALLOWED_HOSTS = eval(os.getenv('ALLOWED_HOSTS'))
# Application definition
@ -54,8 +56,7 @@ ROOT_URLCONF = 'config.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [BASE_DIR / 'templates']
,
'DIRS': [BASE_DIR / 'templates'],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
@ -70,18 +71,20 @@ TEMPLATES = [
WSGI_APPLICATION = 'config.wsgi.application'
# Database
# https://docs.djangoproject.com/en/5.1/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
'ENGINE': 'django.db.backends.postgresql',
'NAME': os.getenv('DB_NAME'),
'USER': os.getenv('DB_USER'),
'PASSWORD': os.getenv('DB_PASSWORD'),
'HOST': os.getenv('DB_HOST'),
'PORT': os.getenv('DB_PORT'),
}
}
# Password validation
# https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators
@ -100,11 +103,10 @@ AUTH_PASSWORD_VALIDATORS = [
},
]
# Internationalization
# https://docs.djangoproject.com/en/5.1/topics/i18n/
LANGUAGE_CODE = 'en-us'
LANGUAGE_CODE = 'en-gb'
TIME_ZONE = 'UTC'
@ -112,11 +114,39 @@ USE_I18N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/5.1/howto/static-files/
STATIC_URL = 'static/'
STATIC_ROOT = BASE_DIR / 'static/'
MEDIA_URL = 'media/'
MEDIA_ROOT = BASE_DIR / 'media/'
# User model and authentication
# LOGIN_REDIRECT_URL = ''
# LOGOUT_REDIRECT_URL = ''
# Email backend configuration
# DEFAULT_FROM_EMAIL = 'calum@drulum.com'
# EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
# EMAIL_HOST = os.getenv('EMAIL_HOST')
# EMAIL_PORT = os.getenv('EMAIL_PORT')
# EMAIL_USE_TLS = (os.getenv('EMAIL_USE_TLS') == 'True')
# EMAIL_HOST_USER = os.getenv('EMAIL_HOST_USER')
# EMAIL_HOST_PASSWORD = os.getenv('EMAIL_HOST_PASSWORD')
# Tagulous config
# SERIALIZATION_MODULES = {
# 'xml': 'tagulous.serializers.xml_serializer',
# 'json': 'tagulous.serializers.json',
# 'python': 'tagulous.serializers.python',
# 'yaml': 'tagulous.serializers.pyyaml',
# }
# Markdownx config
# MARKDOWNX_MARKDOWN_EXTENSIONS = [
# 'markdown.extensions.extra',
# ]
# Default primary key field type
# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field

View File

@ -5,4 +5,6 @@ description = "Add your description here"
requires-python = ">=3.13"
dependencies = [
"django>=5.1.6",
"psycopg>=3.2.4",
"python-dotenv>=1.0.1",
]

29
uv.lock
View File

@ -30,10 +30,37 @@ version = "0.1.0"
source = { virtual = "." }
dependencies = [
{ name = "django" },
{ name = "psycopg" },
{ name = "python-dotenv" },
]
[package.metadata]
requires-dist = [{ name = "django", specifier = ">=5.1.6" }]
requires-dist = [
{ name = "django", specifier = ">=5.1.6" },
{ name = "psycopg", specifier = ">=3.2.4" },
{ name = "python-dotenv", specifier = ">=1.0.1" },
]
[[package]]
name = "psycopg"
version = "3.2.4"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "tzdata", marker = "sys_platform == 'win32'" },
]
sdist = { url = "https://files.pythonhosted.org/packages/e0/f2/954b1467b3e2ca5945b83b5e320268be1f4df486c3e8ffc90f4e4b707979/psycopg-3.2.4.tar.gz", hash = "sha256:f26f1346d6bf1ef5f5ef1714dd405c67fb365cfd1c6cea07de1792747b167b92", size = 156109 }
wheels = [
{ url = "https://files.pythonhosted.org/packages/40/49/15114d5f7ee68983f4e1a24d47e75334568960352a07c6f0e796e912685d/psycopg-3.2.4-py3-none-any.whl", hash = "sha256:43665368ccd48180744cab26b74332f46b63b7e06e8ce0775547a3533883d381", size = 198716 },
]
[[package]]
name = "python-dotenv"
version = "1.0.1"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/bc/57/e84d88dfe0aec03b7a2d4327012c1627ab5f03652216c63d49846d7a6c58/python-dotenv-1.0.1.tar.gz", hash = "sha256:e324ee90a023d808f1959c46bcbc04446a10ced277783dc6ee09987c37ec10ca", size = 39115 }
wheels = [
{ url = "https://files.pythonhosted.org/packages/6a/3e/b68c118422ec867fa7ab88444e1274aa40681c606d59ac27de5a5588f082/python_dotenv-1.0.1-py3-none-any.whl", hash = "sha256:f7b63ef50f1b690dddf550d03497b66d609393b40b564ed0d674909a68ebf16a", size = 19863 },
]
[[package]]
name = "sqlparse"