#29637: KeyError on empty_form.fields in InlineAdminFormSet when user don't have
'add' permission for the child model
-------------------------------------+-------------------------------------
Reporter: Clément Mangin | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 2.1
Severity: Release blocker | Resolution:
Keywords: admin, permission, | Triage Stage: Accepted
inline |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Tim Graham):
{{{ #!diff
diff --git a/django/contrib/admin/options.py
b/django/contrib/admin/options.py
index 0f4dd93..9ff9842 100644
--- a/django/contrib/admin/options.py
+++ b/django/contrib/admin/options.py
@@ -2058,9 +2058,9 @@ class InlineModelAdmin(BaseModelAdmin):
def __init__(self, *args, **kwargs):
super(DeleteProtectedModelForm, self).__init__(*args,
**kwargs)
if not can_change and not self.instance._state.adding:
- self.fields = {}
+ self._meta.exclude = self._meta.fields[:]
if not can_add and self.instance._state.adding:
- self.fields = {}
+ self._meta.exclude = self._meta.fields[:]
def hand_clean_DELETE(self):
"""
}}}
doesn't pass
`admin_views.tests.AdminInlineTests.test_simple_inline_permissions`. I
didn't investigate this approach in detail.
--
Ticket URL: <https://code.djangoproject.com/ticket/29637#comment:6>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/071.9bb10b5eab6197adc2ee795cb38be895%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.