Opened 2 months ago

Closed 2 months ago

#32405 closed Bug (needsinfo)

Inline admin - last related item also hidden when user has no add_permission

Reported by: Pirmin Schneider Owned by: nobody
Component: contrib.admin Version: 3.1
Severity: Normal Keywords: inline admin
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Pirmin Schneider)

Reproduce:

  • Create a TabularInline admin
  • add
def has_add_permission(self, request, obj=None):
    return False

Observed behavior:
The add-button disappears, and the last item of the related inline items disappears.

Expected behavior:
Only the add-button disappears

For some reason the empty-form class is added multiple times. Once (correctly) to the add-row and once to the last form-row (while the add-row is in fact the last row of the table in the DOM)

This LOC in django/contrib/admin/tabular.html seems relevant, although i cannot see the issue there

% if forloop.last and inline_admin_formset.has_add_permission %} empty-form{% endif %}

Change History (2)

comment:1 Changed 2 months ago by Pirmin Schneider

Description: modified (diff)

comment:2 Changed 2 months ago by Mariusz Felisiak

Resolution: needsinfo
Status: newclosed

Thanks for this report, however I cannot reproduce the issue. Can you provide a sample project?

Note: See TracTickets for help on using tickets.
Back to Top