Inline admins broken with UUID parent key and AutoField child key
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)
Owner: |
changed from nobody to Jason Hoos
|
Status: |
new → assigned
|
Severity: |
Normal → Release blocker
|
Triage Stage: |
Unreviewed → Accepted
|
Type: |
Uncategorized → Bug
|
Patch needs improvement: |
set
|
Resolution: |
→ fixed
|
Status: |
assigned → closed
|
Apparently I accidentally undid @timgraham's changes to the ticket when I added my comment for the pull request. Sorry about that.