python - How can I render a list of checkboxes with checkboxes with django? -


i want create form django;

[ ] parent_checkbox1     [ ] sub_cb1_pcb1  [ ] sub_cb2_pcb1 ... [ ] parent_checkbox10   [ ] sub_cb1_pcb10  [ ] sub_cb2_pcb10 

i can render parent checkboxes with:

parent = forms.multiplechoicefield(label="parent",                                        widget=forms.checkboxselectmultiple) self.fields['parent'].choices = 'list of choices' 

but how can add sub_checkboxes parent?

try using jquery dynatree plugin instead. thought of writing custom widget, found 1 easier install , maintain.

for that, you'll need output recursive html:

<div id="tree">    <ul>       <li id="1">element 1</li>       <li id="2">element 2           <ul> ... </ul>       </li>    </ul> </div> 

install js file , call jquery method:

$('#tree').dynatree(parameters); 

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -