From 24b6ad140323f2857eea949252c2088e052e74f2 Mon Sep 17 00:00:00 2001 From: Josh Date: Fri, 13 Sep 2024 10:46:08 -0500 Subject: [PATCH] do not use `conn_max_age` if chosen Django version >= 5.1 --- CHANGELOG.md | 4 ++++ src/django_twc_project/{{ module_name }}/settings.py.jinja | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c53e164..0cc4f90 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] +### Fixed + +- Removed `conn_max_age` argument when configuring database connection if Django version is greater than 5.1. In that case, we enable connection pooling and the `conn_max_age` setting causes the application to error with a `django.core.exceptions.ImproperlyConfigured: Pooling doesn't support persistent connections.` exception. + ## [2024.50] ### Added diff --git a/src/django_twc_project/{{ module_name }}/settings.py.jinja b/src/django_twc_project/{{ module_name }}/settings.py.jinja index 238d21a..36c45a4 100644 --- a/src/django_twc_project/{{ module_name }}/settings.py.jinja +++ b/src/django_twc_project/{{ module_name }}/settings.py.jinja @@ -70,7 +70,9 @@ DATABASES = { "default": env.dj_db_url( "DATABASE_URL", default="sqlite:///db.sqlite3", +{%- if django_version >= "5.1" %} conn_max_age=600, # 10 minutes +{%- endif %} conn_health_checks=True, ssl_require=( # Crunchy Bridge DBs require SSL connections @@ -86,7 +88,9 @@ DATABASES = { EMAIL_RELAY_DATABASE_ALIAS: env.dj_db_url( "EMAIL_RELAY_DATABASE_URL", default="sqlite:///email_relay.sqlite3", +{%- if django_version >= "5.1" %} conn_max_age=600, # 10 minutes +{%- endif %} conn_health_checks=True, ssl_require=( PROD