To illustrate how to deal with MPTT, we will build on top of the ideas app from Chapter 3, Forms and Views. In our changes, we will replace the categories with a hierarchical Category model and update the Idea model to have a many-to-many relationship with the categories. Alternatively, you can create the app from fresh, using only the content shown here, to implement a very basic version of the Idea model from scratch.
Creating hierarchical categories with django-mptt
Getting ready
To get started, perform the following steps:
- Install django-mptt in your virtual environment using the following command:
(env)$ pip install django-mptt==0.10.0
- Create the categories and ideas apps if you have not done so already. Add...