admin.TabularInline has_change_permission bug?

10 views
Skip to first unread message

Andrea

unread,
Dec 18, 2018, 9:59:50 AM12/18/18
to django...@googlegroups.com
Hi everyone,

could anyone confirm the following situation?

I have a problem with the method "has_change_permission" of the "admin.TabularInline" class for a Model, which has a fk to ParentModel.

If I override that method with the following code:

def has_change_permission(self, request, obj=None):
    print(type(obj))
    return super().has_change_permission(request, obj)

When I go to "/admin/foo/parentmodel/add/" to add a new ParentModel in the admin panel:

In Django 2.1.3 I get:

<class 'NoneType'>
<class 'NoneType'>

In Django 2.1.4 I get:

<class 'NoneType'>
<class 'foo.models.ParentModel'>
<class 'NoneType'>

Can anyone reproduce the problem?

Thanks!

Andrea Angelini

Andrea

unread,
Dec 18, 2018, 10:26:36 AM12/18/18
to django...@googlegroups.com
I found the reason:


at this line (1962):

if not inline.has_change_permission(request, obj):

an empty ParentModel is given as `obj` instead of None.

Is this a new behavior or a bug?

Thanks!

Andrea Angelini

Zap 15
Tailored web solutions
www.zap15.com

Reply all
Reply to author
Forward
0 new messages