Using a checkbox list to choose multiple categories in forms with django-mptt

When one or more categories need to be selected at once in a form, you can use the TreeNodeMultipleChoiceField multiple selection field that is provided by django-mptt. However, multiple selection fields (for example, <select multiple>) are not very user-friendly from an interface point of view, as the user needs to scroll and hold control or command keys while clicking to make multiple choices. Especially when there is a fairly large number of items to choose from, and the user wants to select several at once, or the user has accessibility handicaps, such as poor motor control, this can lead to a really awful user experience. A much better approach is to provide a checkbox list from which the user can choose categories. In this recipe, we will create a field that allows you to show the hierarchical tree structure as indented checkboxes in the form.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.226.28.197