-
Book Overview & Buying
-
Table Of Contents
Web Development with Django Cookbook - Second Edition
By :
To illustrate how to deal with MPTT, we will create a movies app that will have a hierarchical Category model and a Movie model with a many-to-many relationship with the categories.
To get started, perform the following steps:
Install django-mptt in your virtual environment using the following command:
(myproject_env)$ pip install django-mptt
Then, create a movies app. Add the movies app as well as mptt to INSTALLED_APPS in the settings, as follows:
# conf/base.py or settings.py
INSTALLED_APPS = (
# ...
"mptt",
"movies",
)We will create a hierarchical Category model and a Movie model, which will have a many-to-many relationship with the categories, as follows:
Open the models.py file and add a Category model that extends mptt.models.MPTTModel and CreationModificationDateMixin, which we defined in Chapter 2, Database Structure. In addition to the fields coming from the mixins, the Category model will need to have a parent...
Change the font size
Change margin width
Change background colour