March 2020
Intermediate to advanced
608 pages
17h 17m
English
To render an indented list of categories with checkboxes, we will create and use a new MultipleChoiceTreeField form field and create an HTML template for this field.
The specific template will be passed to the crispy_forms layout in the form. To do this, perform the following steps:
# myproject/apps/core/form_fields.pyfrom django import formsclass MultipleChoiceTreeField(forms.ModelMultipleChoiceField): widget = forms.CheckboxSelectMultiple def label_from_instance(self, obj): return obj
Read now
Unlock full access