Pre-check Django admin checkboxes

View a Django admin change list view that looks something like this:

enter image description here

I want to pre-check some of the checkboxes in the list. The documentation did not help me further.

Any ideas on how to achieve this in a glorious way? Where, in a good way, I mean as much as possible.

+4
source share
1 answer

You can check the boxes using JavaScript. For example, to flag a item with primary key 1 using jQuery, you would have to:

$(".action-select[value='1']").prop('checked', true);

Or you can use Django in the jQuery bundle if you want:

django.jQuery(".action-select[value='1']").prop('checked', true);
+2
source

Source: https://habr.com/ru/post/1629019/


All Articles