How to do it...

To create a CMS page extension with the CSS class fields for the navigational menu items and page body, follow these steps:

  1. In the models.py file, create a CSSExtension class extending PageExtension, registered in extension_pool and containing fields for the menu item's CSS class and <body> CSS class, as follows:
# cms_extensions/models.py
from django.db import modelsfrom django.utils.translation import ugettext_lazy as _from cms.extensions import PageExtensionfrom cms.extensions.extension_pool import extension_poolMENU_ITEM_CSS_CLASS_CHOICES = (    ("featured", ".featured"),)BODY_CSS_CLASS_CHOICES = (    ("serious", ".serious"),    ("playful", ".playful"),)@extension_pool.registerclass CSSExtension(PageExtension): menu_item_css_class ...

Get Django 2 Web Development Cookbook - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.