From d6eb16a398a8d3a2f58399fd40df7f212680cab0 Mon Sep 17 00:00:00 2001 From: Michael Manfre Date: Mon, 5 Dec 2022 12:55:30 -0500 Subject: Added caching and initial settings --- takahe/settings.py | 11 +++++++++++ takahe/urls.py | 5 +++++ 2 files changed, 16 insertions(+) (limited to 'takahe') diff --git a/takahe/settings.py b/takahe/settings.py index 7952024..9769e98 100644 --- a/takahe/settings.py +++ b/takahe/settings.py @@ -6,6 +6,7 @@ from pathlib import Path from typing import Literal import dj_database_url +import django_cache_url import sentry_sdk from pydantic import AnyUrl, BaseSettings, EmailStr, Field, validator from sentry_sdk.integrations.django import DjangoIntegration @@ -15,6 +16,11 @@ from takahe import __version__ BASE_DIR = Path(__file__).resolve().parent.parent +class CacheBackendUrl(AnyUrl): + host_required = False + allowed_schemes = django_cache_url.BACKENDS.keys() + + class ImplicitHostname(AnyUrl): host_required = False @@ -107,6 +113,9 @@ class Settings(BaseSettings): #: (placeholder setting, no effect) SEARCH: bool = True + #: Default cache backend + CACHES_DEFAULT: CacheBackendUrl | None = None + PGHOST: str | None = None PGPORT: int | None = 5432 PGNAME: str = "takahe" @@ -339,5 +348,7 @@ if SETUP.MEDIA_BACKEND: else: raise ValueError(f"Unsupported media backend {parsed.scheme}") +CACHES = {"default": django_cache_url.parse(SETUP.CACHES_DEFAULT or "dummy://")} + if SETUP.ERROR_EMAILS: ADMINS = [("Admin", e) for e in SETUP.ERROR_EMAILS] diff --git a/takahe/urls.py b/takahe/urls.py index 59f14ba..a6e8a6e 100644 --- a/takahe/urls.py +++ b/takahe/urls.py @@ -55,6 +55,11 @@ urlpatterns = [ admin.BasicSettings.as_view(), name="admin_basic", ), + path( + "admin/tuning/", + admin.TuningSettings.as_view(), + name="admin_tuning", + ), path( "admin/domains/", admin.Domains.as_view(), -- cgit v1.2.3