[Django] #36730: Model validation of constraints fails for *excluded* ForeignKeys referenced by attname

13 views
Skip to first unread message

Django

unread,
Nov 12, 2025, 2:43:41 PM11/12/25
to django-...@googlegroups.com
#36730: Model validation of constraints fails for *excluded* ForeignKeys referenced
by attname
-------------------------------------+-------------------------------------
Reporter: Adam | Owner: Adam Johnson
Johnson |
Type: Bug | Status: assigned
Component: Database | Version: 6.0
layer (models, ORM) |
Severity: Release | Keywords:
blocker |
Triage Stage: | Has patch: 1
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Like #36433, but for the case where the foreign gets excluded by the form
due to already being invalid. Another 6.0 release blocker, as forms that
would validate before now crash with `FieldError`. Bisected to
e44e8327d3d88d86895735c0e427102063ff5b55 as well.

Reproduction repository: (pending)
--
Ticket URL: <https://code.djangoproject.com/ticket/36730>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Nov 12, 2025, 2:44:55 PM11/12/25
to django-...@googlegroups.com
#36730: Model validation of constraints fails for *excluded* ForeignKeys referenced
by attname
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Adam
| Johnson
Type: Bug | Status: assigned
Component: Database layer | Version: 6.0
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Adam Johnson:

Old description:

> Like #36433, but for the case where the foreign gets excluded by the form
> due to already being invalid. Another 6.0 release blocker, as forms that
> would validate before now crash with `FieldError`. Bisected to
> e44e8327d3d88d86895735c0e427102063ff5b55 as well.
>
> Reproduction repository: (pending)

New description:

Like #36433, but for the case where the foreign gets excluded by the form
due to already being invalid. Another 6.0 release blocker, as forms that
would validate before now crash with `FieldError`. Bisected to
e44e8327d3d88d86895735c0e427102063ff5b55 as well.

Reproduction repository: https://github.com/adamchainz/django-ticket-36730

--
--
Ticket URL: <https://code.djangoproject.com/ticket/36730#comment:1>

Django

unread,
Nov 12, 2025, 2:55:48 PM11/12/25
to django-...@googlegroups.com
#36730: Model validation of constraints fails for *excluded* ForeignKeys referenced
by attname
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Adam
| Johnson
Type: Bug | Status: assigned
Component: Database layer | Version: 6.0
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* stage: Unreviewed => Accepted

Comment:

Thanks for the repro!
--
Ticket URL: <https://code.djangoproject.com/ticket/36730#comment:2>

Django

unread,
Nov 12, 2025, 3:07:05 PM11/12/25
to django-...@googlegroups.com
#36730: Model validation of constraints fails for *excluded* ForeignKeys referenced
by attname
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Adam
| Johnson
Type: Bug | Status: assigned
Component: Database layer | Version: 6.0
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* needs_better_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/36730#comment:3>

Django

unread,
Nov 13, 2025, 3:21:25 AM11/13/25
to django-...@googlegroups.com
#36730: Model validation of constraints fails for *excluded* ForeignKeys referenced
by attname
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Adam
| Johnson
Type: Bug | Status: assigned
Component: Database layer | Version: 6.0
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* needs_better_patch: 1 => 0
* stage: Accepted => Ready for checkin

--
Ticket URL: <https://code.djangoproject.com/ticket/36730#comment:4>

Django

unread,
Nov 13, 2025, 4:04:00 AM11/13/25
to django-...@googlegroups.com
#36730: Model validation of constraints fails for *excluded* ForeignKeys referenced
by attname
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Adam
| Johnson
Type: Bug | Status: closed
Component: Database layer | Version: 6.0
(models, ORM) |
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* resolution: => fixed
* status: assigned => closed

Comment:

In [changeset:"abfa4619fb818ff694c22e962a280673e085239e" abfa461]:
{{{#!CommitTicketReference repository=""
revision="abfa4619fb818ff694c22e962a280673e085239e"
Fixed #36730 -- Fixed constraint validation crash for excluded FK
attnames.

Regression in e44e8327d3d88d86895735c0e427102063ff5b55.

Co-authored-by: Mariusz Felisiak <felisiak...@gmail.com>
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36730#comment:5>

Django

unread,
Nov 13, 2025, 4:05:03 AM11/13/25
to django-...@googlegroups.com
#36730: Model validation of constraints fails for *excluded* ForeignKeys referenced
by attname
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Adam
| Johnson
Type: Bug | Status: closed
Component: Database layer | Version: 6.0
(models, ORM) |
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"5ae8659cb5beb9e4bea36a1c1b2e443bff4f3873" 5ae8659]:
{{{#!CommitTicketReference repository=""
revision="5ae8659cb5beb9e4bea36a1c1b2e443bff4f3873"
[6.0.x] Fixed #36730 -- Fixed constraint validation crash for excluded FK
attnames.

Regression in e44e8327d3d88d86895735c0e427102063ff5b55.

Co-authored-by: Mariusz Felisiak <felisiak...@gmail.com>

Backport of abfa4619fb818ff694c22e962a280673e085239e from main
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36730#comment:6>
Reply all
Reply to author
Forward
0 new messages