#30050 closed Bug (fixed)
InlineModelAdmin.has_change_permission() incorrectly called with non-None obj during add
| Reported by: | Andrea Angelini | Owned by: | nobody |
|---|---|---|---|
| Component: | contrib.admin | Version: | 2.1 |
| Severity: | Release blocker | Keywords: | |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description (last modified by )
Fine with Django 2.1.3, bug with Django 2.1.4.
If I have an admin Inline of a Model, with fk to a ParentModel, when I try to add a new ParentModel in the admin panel ("/admin/foo/parentmodel/add/"), the Inline has_change_permission is called 3 times instead of 2, after this commit:
https://github.com/django/django/commit/27f5b0aff3442e5c25e84972dff4f5fe1edd4e68
at line 1962 has_change_permission is passed an obj that is not None.
Before this commit, obj was None both of the times, now it's None the first time, an empty instance of ParentModel the second time, and None the third time.
Line 1962 should be something like:
permission_obj = obj if change else None
if not inline.has_change_permission(request, permission_obj):
Change History (5)
comment:1 by , 7 years ago
| Description: | modified (diff) |
|---|
comment:2 by , 7 years ago
| Severity: | Normal → Release blocker |
|---|---|
| Summary: | admin.TabularInline has_change_permission obj is not None on add → InlineModelAdmin.has_change_permission() incorrectly called with non-None obj during add |
| Triage Stage: | Unreviewed → Accepted |
comment:3 by , 7 years ago
| Has patch: | set |
|---|
PR