Opened 6 years ago

Last modified 6 years ago

#30050 closed Bug

admin.TabularInline has_change_permission obj is not None on add — at Version 1

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 Andrea Angelini)

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 (1)

comment:1 by Andrea Angelini, 6 years ago

Description: modified (diff)
Last edited 6 years ago by Tim Graham (previous) (diff)
Note: See TracTickets for help on using tickets.
Back to Top