Opened 3 months ago

Closed 3 months ago

#33679 closed Bug (fixed)

"empty" suffix gets added to last (original) admin inline form row for readonly views

Reported by: Daniel Hahler Owned by: Daniel Hahler
Component: contrib.admin Version: 4.0
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


django/contrib/admin/templates/admin/edit_inline/tabular.html has the following code:

        <tr class="form-row {% if inline_admin_form.original or inline_admin_form.show_url %}has_original{% endif %}{% if forloop.last and inline_admin_formset.has_add_permission %} empty-form{% endif %}"
             id="{{ inline_admin_formset.formset.prefix }}-{% if not forloop.last %}{{ forloop.counter0 }}{% else %}empty{% endif %}">

The condition for adding the "empty" suffix to the id does not work when the object is readonly (no has_add_permission).

I think it should use the same condition as with the handling of the empty-form class.

The empty row gets added based on this in the first place:

ref (added in):

Change History (3)

comment:1 Changed 3 months ago by Mariusz Felisiak

Has patch: set
Owner: changed from nobody to Daniel Hahler
Status: newassigned
Triage Stage: UnreviewedAccepted

Good catch!


comment:2 Changed 3 months ago by Mariusz Felisiak

Triage Stage: AcceptedReady for checkin

comment:3 Changed 3 months ago by Mariusz Felisiak <felisiak.mariusz@…>

Resolution: fixed
Status: assignedclosed

In dddc8bc:

Fixed #33679 -- Fixed the last inline's id in admin for users without add permissions.

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