Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#24958 closed Bug (fixed)

Inline admins broken with UUID parent key and AutoField child key

Reported by: Jason Hoos Owned by: Jason Hoos
Component: Forms Version: 1.8
Severity: Release blocker Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

If you have a parent model that has a UUIDField as a primary key, and a child model that uses the default AutoField as its primary key, then an admin form that uses an inline form containing that child model will fail with a Please correct the errors below. message with no other errors on the form.

The underlying cause turned out to be related to issue #24377. The fix for that issue accounted for both parent and child being UUID-based, but not for the mixed case. Specifically, in the add_fields method of BaseInlineFormSet, #24377 checks to see if the parent object is being added, and then checks to see whether the primary key field on the child object is using a generated default value. It should instead be checking whether the related key field on the parent object is using a generated value.

I have a pull request with a potential fix for this issue. It also fixes the similar case where the AutoField child model is related to a UUIDField alternate key in the parent model.

Change History (8)

comment:1 Changed 5 years ago by Jason Hoos

comment:2 Changed 5 years ago by Jason Hoos

Owner: changed from nobody to Jason Hoos
Status: newassigned

comment:3 Changed 5 years ago by Tim Graham

Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted
Type: UncategorizedBug

comment:4 Changed 5 years ago by Jason Hoos

Severity: Release blockerNormal
Triage Stage: AcceptedUnreviewed
Type: BugUncategorized

comment:5 Changed 5 years ago by Jason Hoos

Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted
Type: UncategorizedBug

Apparently I accidentally undid timgraham's changes to the ticket when I added my comment for the pull request. Sorry about that.

Last edited 5 years ago by Jason Hoos (previous) (diff)

comment:6 Changed 5 years ago by Tim Graham

Patch needs improvement: set

comment:7 Changed 5 years ago by Tim Graham <timograham@…>

Resolution: fixed
Status: assignedclosed

In a50b66d:

Fixed #24958 -- Fixed inline forms using UUID-PK parents with auto-PK children.

comment:8 Changed 5 years ago by Tim Graham <timograham@…>

In 42968014:

[1.8.x] Fixed #24958 -- Fixed inline forms using UUID-PK parents with auto-PK children.

Backport of a50b66da30320887c23c73927f6b2ab41e0301bf from master

Note: See TracTickets for help on using tickets.
Back to Top