Opened 9 years ago

Closed 9 years ago

Last modified 2 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 (7)

comment:1 by Jason Hoos, 9 years ago

comment:2 by Jason Hoos, 9 years ago

Owner: changed from nobody to Jason Hoos
Status: newassigned

comment:3 by Tim Graham, 9 years ago

Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted
Type: UncategorizedBug

comment:5 by Jason Hoos, 9 years ago

Last edited 2 years ago by Tim Graham (previous) (diff)

comment:6 by Tim Graham, 9 years ago

Patch needs improvement: set

comment:7 by Tim Graham <timograham@…>, 9 years ago

Resolution: fixed
Status: assignedclosed

In a50b66d:

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

comment:8 by Tim Graham <timograham@…>, 9 years ago

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