In django admin inline forms, there are checkboxes for deleting individual inline objects. Is there a way to enable selecting all of them at once for deletion?
Here's a solution I worked out:
In templates/admin/edit_inline/tabular.html
{% if inline_admin_formset.formset.can_delete %}<th>{% trans "Delete?" %} <input type="checkbox" class="selectall_checkbox"/></th>{% endif %}
and
<script type="text/javascript">
$('.selectall_checkbox').click(function(e) {
$(e.target).closest('table').find(':checkbox').filter(function () { return /DELETE/.test(this.name); }).each(function () {
this.checked = e.target.checked;
});
});
</script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With