New in version 3.2.

Content creation wizards

django CMS offers a framework for creating ‘wizards’ - helpers - for content editors.

They provide a simplified workflow for common tasks.

A django CMS Page wizard already exists, but you can create your own for other content types very easily.

Create a content-creation wizard

Creating a CMS content creation wizard for your own module is fairly easy.

To begin, create a file in the root level of your module called cms_wizards.py. In this file, import Wizard as follows:

  1. from cms.wizards.wizard_base import Wizard
  2. from cms.wizards.wizard_pool import wizard_pool

Then, simply subclass Wizard, instantiate it, then register it. If you were to do this for MyApp, it might look like this:

  1. # my_apps/cms_wizards.py
  2. from cms.wizards.wizard_base import Wizard
  3. from cms.wizards.wizard_pool import wizard_pool
  4. from .forms import MyAppWizardForm
  5. from .models import MyApp
  6. class MyAppWizard(Wizard):
  7. pass
  8. my_app_wizard = MyAppWizard(
  9. title="New MyApp",
  10. weight=200,
  11. form=MyAppWizardForm,
  12. description="Create a new MyApp instance",
  13. )
  14. wizard_pool.register(my_app_wizard)

And you need a form:

  1. # my_apps/forms.py
  2. from django import forms
  3. class MyAppWizardForm(forms.ModelForm):
  4. class Meta:
  5. model = MyApp
  6. exclude = []

That’s it!

Note

the module name cms_wizards is special, in that any such-named modules in your project’s Python path will automatically be loaded, triggering the registration of any wizards found in them. Wizards may be declared and registered in other modules, but they might not be automatically loaded.

The above example is using a ModelForm, but you can also use forms.Form. In this case, you must provide the model class as another keyword argument when you instantiate the Wizard object.

You must subclass cms.wizards.wizard_base.Wizard to use it. This is because each wizard’s uniqueness is determined by its class and module name.

See the Reference section on wizards for technical details of the wizards API.