https://github.com/realorangeone/django-generic-relation-db-repro
A repository to reproduce a bug with modifying generic relations, where the wrong database connection is used.
https://github.com/realorangeone/django-generic-relation-db-repro
bug django
Last synced: 23 days ago
JSON representation
A repository to reproduce a bug with modifying generic relations, where the wrong database connection is used.
- Host: GitHub
- URL: https://github.com/realorangeone/django-generic-relation-db-repro
- Owner: RealOrangeOne
- Created: 2025-05-13T15:15:04.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2025-05-13T15:39:06.000Z (about 1 year ago)
- Last Synced: 2026-05-05T20:46:18.478Z (about 1 month ago)
- Topics: bug, django
- Language: Python
- Homepage: https://code.djangoproject.com/ticket/36389
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Django generic relation reproduction
A repository to reproduce a bug with modifying generic relations, where the wrong database connection is used.
Confirmed on Django 4.2, 5.0, 5.1 and 5.2.
# Usage
```
uv venv
uv pip install django
.venv/bin/python ./manage.py test
```
When running the tests, they'll fail. The failure shows queries being executed against the replica connection. Since they're `UPDATE` queries, they should run against the "default" connection, instead.
# Steps to recreate
1. `django-admin startproject`
2. Create second database connection, pointing to the same database, but using MIRROR in tests.
3. Create a database router to use the secondary connection for reads and the default for writes (see `db_router.py`).
4. Create 2 models, with a generic relationship between them (see `models.py`).