From 2a774287016fc0941bf1253fa5799ab63e80d09d Mon Sep 17 00:00:00 2001 From: Ray <44787842+OutboundSpade@users.noreply.github.com> Date: Thu, 4 Dec 2025 13:03:19 -0500 Subject: [PATCH 1/3] Update psycopg to version 3 to support pooling --- requirements/local.txt | 2 +- requirements/production.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements/local.txt b/requirements/local.txt index 797b21b..3fa4903 100644 --- a/requirements/local.txt +++ b/requirements/local.txt @@ -2,7 +2,7 @@ Werkzeug==3.0.3 # https://github.com/pallets/werkzeug ipdb==0.13.13 # https://github.com/gotcha/ipdb -psycopg2-binary==2.9.9 # https://github.com/psycopg/psycopg2 +psycopg[binary]>=3.0.0 # https://github.com/psycopg/psycopg watchgod==0.8.2 # https://github.com/samuelcolvin/watchgod # Testing diff --git a/requirements/production.txt b/requirements/production.txt index 1c04c47..7c6cfd5 100644 --- a/requirements/production.txt +++ b/requirements/production.txt @@ -4,7 +4,7 @@ wheel==0.43.0 # https://idk gunicorn==22.0.0 # https://github.com/benoitc/gunicorn -psycopg2-binary==2.9.9 # https://github.com/psycopg/psycopg2 +psycopg[binary]>=3.0.0 # https://github.com/psycopg/psycopg Collectfast==2.2.0 # https://github.com/antonagestam/collectfast boto3==1.34.145 From bb0a5cb986654f0740833e9fed89fa605d625b83 Mon Sep 17 00:00:00 2001 From: Ray <44787842+OutboundSpade@users.noreply.github.com> Date: Thu, 4 Dec 2025 13:14:46 -0500 Subject: [PATCH 2/3] Enable connection pooling by default --- config/settings/base.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/settings/base.py b/config/settings/base.py index bb00729..9a6900e 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -46,6 +46,8 @@ "default": env.db("DATABASE_URL", default="postgres:///teleband"), } DATABASES["default"]["ATOMIC_REQUESTS"] = True +DATABASES["default"]["OPTIONS"] = {"pool": True} + # https://docs.djangoproject.com/en/stable/ref/settings/#std:setting-DEFAULT_AUTO_FIELD DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" From 1c8f652f6679219204a1883853db54eb3b24b687 Mon Sep 17 00:00:00 2001 From: Ray <44787842+OutboundSpade@users.noreply.github.com> Date: Thu, 4 Dec 2025 13:20:38 -0500 Subject: [PATCH 3/3] Fix formatting for settings --- config/settings/local.py | 11 ++++++++++- config/settings/production.py | 5 ++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/config/settings/local.py b/config/settings/local.py index 4e9f51e..6f37b8f 100644 --- a/config/settings/local.py +++ b/config/settings/local.py @@ -14,7 +14,16 @@ "default": env.db("DATABASE_URL", default="sqlite:///db.sqlite"), } # https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts -ALLOWED_HOSTS = env.list("ALLOWED_HOSTS", default=["localhost", "0.0.0.0", "127.0.0.1", "dev-api.musiccpr.org", "api.musiccpr.org"]) +ALLOWED_HOSTS = env.list( + "ALLOWED_HOSTS", + default=[ + "localhost", + "0.0.0.0", + "127.0.0.1", + "dev-api.musiccpr.org", + "api.musiccpr.org", + ], +) # CACHES # ------------------------------------------------------------------------------ diff --git a/config/settings/production.py b/config/settings/production.py index 09441f5..336f438 100644 --- a/config/settings/production.py +++ b/config/settings/production.py @@ -7,7 +7,10 @@ # https://docs.djangoproject.com/en/dev/ref/settings/#secret-key SECRET_KEY = env("DJANGO_SECRET_KEY") # https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts -ALLOWED_HOSTS = env.list("DJANGO_ALLOWED_HOSTS", default=["https://tele.band", "dev-api.musiccpr.org", "api.musiccpr.org"]) +ALLOWED_HOSTS = env.list( + "DJANGO_ALLOWED_HOSTS", + default=["https://tele.band", "dev-api.musiccpr.org", "api.musiccpr.org"], +) # DATABASES # ------------------------------------------------------------------------------