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 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/
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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.