Reputation: 6896
Consider a Django Admin changelist view looking somewhat like this:
I would like to pre-check some of the checkboxes in the list. Documentation didn't help me further.
Any ideas on how to achieve this in a nice way? Where by nice I mean, as standard as possible.
Upvotes: 4
Views: 469
Reputation: 308999
You could tick the checkboxes using JavaScript. For example, to tick the checkbox for the item with primary key 1, using jQuery, you would do:
$(".action-select[value='1']").prop('checked', true);
Or you could use Django's bundled jQuery if you want:
django.jQuery(".action-select[value='1']").prop('checked', true);
Upvotes: 2