From 2995aeab56d661663e2851b29bba1fc20c2541f0 Mon Sep 17 00:00:00 2001 From: Willem Van Onsem Date: Sun, 21 Apr 2024 20:06:12 +0200 Subject: Fixed #35393 -- Added excluded pk as a hidden field to the inline admin. --- django/contrib/admin/helpers.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'django') diff --git a/django/contrib/admin/helpers.py b/django/contrib/admin/helpers.py index a4aa8e40e3..d28a382814 100644 --- a/django/contrib/admin/helpers.py +++ b/django/contrib/admin/helpers.py @@ -509,6 +509,11 @@ class InlineAdminForm(AdminForm): # Auto fields are editable, so check for auto or non-editable pk. self.form._meta.model._meta.auto_field or not self.form._meta.model._meta.pk.editable + # The pk can be editable, but excluded from the inline. + or ( + self.form._meta.exclude + and self.form._meta.model._meta.pk.name in self.form._meta.exclude + ) or # Also search any parents for an auto field. (The pk info is # propagated to child models so that does not need to be checked -- cgit v1.3