What happens if you want to show category selection in a form? How will the hierarchy be presented? In django-mptt, there is a special TreeNodeChoiceField form field that you can use to show the hierarchical structures in a selected field. Let's take a look at how to do this.
Using a single selection field to choose a category in forms with django-mptt
Getting ready
We will start with the categories and ideas apps that we defined in the previous recipes. For this recipe, we will also need django-crispy-forms. Have a look at how to install it in the Creating a form layout with django-crispy-forms recipe in Chapter 3, Forms and Views.