Skip to content

Commit 452a5b1

Browse files
matrixiseclaude
andauthored
fix: Add PostgreSQL support for Django 6.0 compatibility
* πŸš€ feat: upgrade to Django 6.0 Upgrade Django from 5.2.9 to 6.0 by updating requirements files. - Update requirements/main.txt: Django 5.2.9 β†’ 6.0 - Update requirements/dev.txt: Django 5.2.9 β†’ 6.0 - All 33 tests pass successfully - Wagtail 7.2.1 supports Django 6.0 Django 6.0 was released on December 3, 2025: https://docs.djangoproject.com/en/6.0/releases/6.0/ Wagtail 7.2.x supports Django 6.0: wagtail/wagtail#13622 Closes #173 * fix: add django.contrib.postgres to INSTALLED_APPS for Django 6.0 Django 6.0 requires django.contrib.postgres to be explicitly added to INSTALLED_APPS when using PostgreSQL-specific features like SearchVectorField and GinIndex. This fixes the Heroku deployment error: wagtailsearch.IndexEntry: (postgres.E005) 'django.contrib.postgres' must be in INSTALLED_APPS in order to use SearchVectorField and GinIndex. Fixes deployment issue with Django 6.0 upgrade from PR #179. πŸ€– Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * fix: configure PostgreSQL for CI tests and move psycopg to main dependencies Changes: - Add PostgreSQL 17 service to GitHub Actions workflow - Configure tests to use PostgreSQL in CI (via DATABASE_URL) while keeping SQLite for local development - Move psycopg[binary] from production.in to main.in since django.contrib.postgres is now in base INSTALLED_APPS - Update workflow to install production.txt dependencies - Recompile all requirements files This fixes the test failure where django.contrib.postgres required psycopg to be installed but it was only available in production dependencies, not in the CI test environment. The conditional database configuration in tests.py allows: - CI: Uses PostgreSQL (matching production environment) - Local dev: Uses SQLite (simpler setup without PostgreSQL requirement) Fixes the Django 6.0 compatibility issue from the previous commit. --------- Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 25078af commit 452a5b1

8 files changed

Lines changed: 39 additions & 21 deletions

File tree

β€Ž.github/workflows/test.ymlβ€Ž

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,25 @@ jobs:
55
build:
66
name: Execute tests
77
runs-on: ubuntu-latest
8+
9+
services:
10+
postgres:
11+
image: postgres:17
12+
env:
13+
POSTGRES_PASSWORD: postgres
14+
POSTGRES_DB: test_db
15+
options: >-
16+
--health-cmd pg_isready
17+
--health-interval 10s
18+
--health-timeout 5s
19+
--health-retries 5
20+
ports:
21+
- 5432:5432
22+
823
env:
924
DJANGO_SETTINGS_MODULE: pythonie.settings.tests
25+
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/test_db
26+
1027
steps:
1128
- uses: actions/checkout@v2
1229
- name: Set Up Python 3.12
@@ -16,7 +33,7 @@ jobs:
1633
- name: Install the dependencies
1734
run: |
1835
python -m pip install --upgrade pip setuptools uv
19-
python -m uv pip install -r requirements/main.txt -r requirements/dev.txt
36+
python -m uv pip install -r requirements/main.txt -r requirements/dev.txt -r requirements/production.txt
2037
- name: Run the tests
2138
run: |
2239
python pythonie/manage.py test pythonie --verbosity=2

β€Žpythonie/pythonie/settings/base.pyβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"django.contrib.sessions",
4444
"django.contrib.messages",
4545
"django.contrib.staticfiles",
46+
"django.contrib.postgres",
4647
"compressor",
4748
"taggit",
4849
"modelcluster",

β€Žpythonie/pythonie/settings/tests.pyβ€Ž

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,17 @@
1010

1111
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
1212

13-
# SQLite (simplest install)
14-
DATABASES = {
15-
"default": {
16-
"ENGINE": "django.db.backends.sqlite3",
17-
"NAME": join(PROJECT_ROOT, "db.sqlite3"),
13+
# Use PostgreSQL if DATABASE_URL is set (for CI), otherwise use SQLite (for local tests)
14+
if os.getenv("DATABASE_URL"):
15+
DATABASES = {"default": dj_database_url.config(conn_max_age=500)}
16+
else:
17+
# SQLite (simplest install for local development)
18+
DATABASES = {
19+
"default": {
20+
"ENGINE": "django.db.backends.sqlite3",
21+
"NAME": join(PROJECT_ROOT, "db.sqlite3"),
22+
}
1823
}
19-
}
2024

2125
LOGGING.update(
2226
{

β€Žrequirements/dev.txtβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ defusedxml==0.7.1
2424
# via
2525
# -c requirements/main.txt
2626
# py-serializable
27-
django==5.2.9
27+
django==6.0
2828
# via
2929
# -c requirements/main.txt
3030
# django-debug-toolbar

β€Žrequirements/main.inβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ django-storages
1515
django-taggit
1616
gunicorn
1717
pandas
18+
psycopg[binary]
1819
pydantic
1920
python-dateutil
2021
pytz

β€Žrequirements/main.txtβ€Ž

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ dj-database-url==3.0.1
3232
# via -r requirements/main.in
3333
dj-static==0.0.6
3434
# via -r requirements/main.in
35-
django==5.2.9
35+
django==6.0
3636
# via
3737
# -r requirements/main.in
3838
# dj-database-url
@@ -123,6 +123,10 @@ pillow==12.0.0
123123
# wagtail
124124
pillow-heif==1.1.1
125125
# via willow
126+
psycopg==3.3.2
127+
# via -r requirements/main.in
128+
psycopg-binary==3.3.2
129+
# via psycopg
126130
pydantic==2.12.5
127131
# via -r requirements/main.in
128132
pydantic-core==2.41.5
@@ -167,6 +171,7 @@ typing-extensions==4.15.0
167171
# beautifulsoup4
168172
# django-stubs-ext
169173
# django-tasks
174+
# psycopg
170175
# pydantic
171176
# pydantic-core
172177
# typing-inspection

β€Žrequirements/production.inβ€Ž

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
# This file was autogenerated by uv via the following command:
2-
# uv pip compile --output-file requirements/production.in requirements/production.txt
3-
-c main.txt
4-
psycopg[binary]
1+
# production.in
2+
-c main.txt

β€Žrequirements/production.txtβ€Ž

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,2 @@
11
# This file was autogenerated by uv via the following command:
22
# uv pip compile --output-file requirements/production.txt requirements/production.in
3-
psycopg==3.2.13
4-
# via -r requirements/production.in
5-
psycopg-binary==3.2.13
6-
# via psycopg
7-
typing-extensions==4.15.0
8-
# via
9-
# -c requirements/main.txt
10-
# psycopg

0 commit comments

Comments
Β (0)