PenParse/penparse/config/settings.py

171 lines
4.3 KiB
Python
Raw Permalink Normal View History

2024-11-23 12:28:00 +00:00
"""
Django settings for penparse project.
Generated by 'django-admin startproject' using Django 4.2.16.
For more information on this file, see
https://docs.djangoproject.com/en/4.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.2/ref/settings/
"""
2024-12-10 12:04:26 +00:00
import os
2024-11-23 12:28:00 +00:00
from pathlib import Path
2024-12-10 12:04:26 +00:00
from dotenv import load_dotenv
load_dotenv()
2024-11-23 12:28:00 +00:00
# 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/4.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
2024-12-10 12:04:26 +00:00
SECRET_KEY = "django-insecure-t5yq5dlvztd^-oq%*($@lj$$33l_73e05093xw7s0)-ekqhtfn"
2024-11-23 12:28:00 +00:00
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
2024-12-10 12:04:26 +00:00
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
2024-12-20 09:47:00 +00:00
"penparse",
2024-12-10 16:05:24 +00:00
"markdown_deux",
"markdownify.apps.MarkdownifyConfig",
2024-12-18 21:35:31 +00:00
"rest_framework",
"rest_framework.authtoken",
"django_filters",
2024-11-23 12:28:00 +00:00
]
MIDDLEWARE = [
2024-12-10 12:04:26 +00:00
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
2024-11-23 12:28:00 +00:00
]
2024-12-18 21:35:31 +00:00
REST_FRAMEWORK = {
# Use Django's standard `django.contrib.auth` permissions,
# or allow read-only access for unauthenticated users.
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly'
2024-12-21 11:45:16 +00:00
],
'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework.authentication.BasicAuthentication',
'rest_framework.authentication.TokenAuthentication',
2024-12-18 21:35:31 +00:00
]
}
2024-12-20 11:25:14 +00:00
ROOT_URLCONF = "config.urls"
2024-11-23 12:28:00 +00:00
TEMPLATES = [
{
2024-12-10 12:04:26 +00:00
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
2024-11-23 12:28:00 +00:00
],
},
},
]
2024-12-10 16:05:24 +00:00
MARKDOWNIFY = {
"default": {
"MARKDOWN_EXTENSIONS": [
"markdown.extensions.fenced_code", # dotted path
"fenced_code", # also works
]
}
}
2024-12-20 11:25:14 +00:00
WSGI_APPLICATION = "config.wsgi.application"
2024-11-23 12:28:00 +00:00
# Database
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
DATABASES = {
2024-12-10 12:04:26 +00:00
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR / "db.sqlite3",
2024-11-23 12:28:00 +00:00
}
}
# Password validation
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
2024-12-10 12:04:26 +00:00
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
2024-11-23 12:28:00 +00:00
},
{
2024-12-10 12:04:26 +00:00
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
2024-11-23 12:28:00 +00:00
},
{
2024-12-10 12:04:26 +00:00
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
2024-11-23 12:28:00 +00:00
},
{
2024-12-10 12:04:26 +00:00
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
2024-11-23 12:28:00 +00:00
},
]
2024-12-10 12:04:26 +00:00
LOGIN_REDIRECT_URL = "/dashboard"
2024-11-23 12:28:00 +00:00
2024-12-20 09:47:00 +00:00
AUTH_USER_MODEL = "penparse.User"
2024-11-24 07:45:02 +00:00
2024-12-20 09:47:00 +00:00
AUTHENTICATION_BACKENDS = ["penparse.auth.EmailBackend"]
2024-11-24 07:45:02 +00:00
2024-11-23 12:28:00 +00:00
# Internationalization
# https://docs.djangoproject.com/en/4.2/topics/i18n/
2024-12-10 12:04:26 +00:00
LANGUAGE_CODE = "en-gb"
2024-11-23 12:28:00 +00:00
2024-12-10 12:04:26 +00:00
TIME_ZONE = "UTC"
2024-11-23 12:28:00 +00:00
USE_I18N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.2/howto/static-files/
2024-12-10 12:04:26 +00:00
STATIC_URL = "static/"
2024-11-23 12:28:00 +00:00
# Default primary key field type
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
2024-12-10 12:04:26 +00:00
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
2024-12-20 09:47:00 +00:00
CELERY_BROKER_URL = os.getenv("CELERY_BROKER_URL")
2024-12-08 12:09:48 +00:00
2024-12-10 12:04:26 +00:00
OPENAI_API_BASE = os.getenv("OPENAI_API_BASE")
2024-12-15 06:35:39 +00:00
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
2024-12-18 21:35:31 +00:00
# OPENAI_API_KEY = "test"
2024-12-10 12:04:26 +00:00
OPENAI_MODEL = os.getenv("OPENAI_MODEL", "openai/gpt-4o")
2024-12-18 21:35:31 +00:00
# OPENAI_MODEL="ollama/llama3.2-vision"