Skip to content

Conversation

@matrixise
Copy link
Contributor

Summary

This PR fixes the Django 6.0 compatibility issue by adding proper PostgreSQL support for tests and moving psycopg to main dependencies.

Problem

After upgrading to Django 6.0, Wagtail requires django.contrib.postgres to be in INSTALLED_APPS when using PostgreSQL-specific features like SearchVectorField and GinIndex. However, adding this to INSTALLED_APPS caused CI tests to fail because:

  1. django.contrib.postgres requires psycopg to be installed
  2. psycopg was only in requirements/production.txt
  3. CI tests only installed main.txt and dev.txt
  4. Tests failed with ModuleNotFoundError: No module named 'psycopg'

Solution

1. Add PostgreSQL to CI Tests (.github/workflows/test.yml)

  • Added PostgreSQL 17 service to GitHub Actions
  • Configured DATABASE_URL to use PostgreSQL in CI
  • Tests now run in an environment similar to production

2. Conditional Database Configuration (pythonie/pythonie/settings/tests.py)

  • Tests use PostgreSQL when DATABASE_URL is set (CI)
  • Tests use SQLite when DATABASE_URL is not set (local development)
  • Maintains simplicity for local development while ensuring production-like testing in CI

3. Move psycopg to Main Dependencies

  • Moved psycopg[binary] from requirements/production.in to requirements/main.in
  • Since django.contrib.postgres is now in base INSTALLED_APPS, psycopg is a core dependency
  • Recompiled all requirements files

Changes

  • ✅ PostgreSQL 17 service added to GitHub Actions
  • ✅ Conditional database configuration for tests
  • ✅ psycopg moved to main dependencies
  • ✅ All tests passing in CI

Testing

Related Issues

Fixes the deployment error from Django 6.0 upgrade:

wagtailsearch.IndexEntry: (postgres.E005) 'django.contrib.postgres' must be 
in INSTALLED_APPS in order to use SearchVectorField and GinIndex.

Checklist

  • Tests pass in CI
  • PostgreSQL compatibility verified
  • Local development workflow maintained
  • Requirements files updated and recompiled

matrixise and others added 3 commits December 24, 2025 12:32
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
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>
…dencies

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.
@matrixise matrixise merged commit 452a5b1 into master Dec 24, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants