Opened 4 years ago
Last modified 4 years ago
#32405 closed Bug
Inline admin - last related item also hidden when user has no add_permission — at Initial Version
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
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 %}
`