Content creation wizards

    See the How-to section on wizards for an introduction to creating wizards.

    Wizard classes are sub-classes of cms.wizards.wizard_base.Wizard.

    They need to be registered with the cms.wizards.wizard_pool.wizard_pool:

    Finally, a wizard needs to be instantiated, for example:

    1. my_app_wizard = MyAppWizard(
    2. title="New MyApp",
    3. weight=200,
    4. form=MyAppWizardForm,
    5. description="Create a new MyApp instance",
    6. )

    When instantiating a Wizard object, use the keywords:

    All wizard classes should inherit from cms.wizards.wizard_base.Wizard. This class implements a number of methods that may be overridden as required.

    Simply returns the description property assigned during instantiation or one derived from the model if description is not provided during instantiation. Override this method if this needs to be determined programmatically.

    get_title

    get_success_url

    Once the wizard has completed, the user will be redirected to the URL of the new object that was created. By default, this is done by return the result of calling the get_absolute_url method on the object. This may then be modified to force the user into edit mode if the wizard property edit_mode_on_success is True.

    In some cases, the created content will not implement get_absolute_url or that redirecting the user is undesirable. In these cases, simply override this method. If get_success_url returns None, the CMS will just redirect to the current page after the object is created.

    This method is called by the CMS with the parameter:

    Simply returns the weight property assigned during instantiation. Override this method if this needs to be determined programmatically.

    user_has_add_permission

    This should return a boolean reflecting whether the user has permission to create the underlying content for the wizard.

    This method is called by the CMS with these parameters:

    includes a read-only property discovered which returns the Boolean True if wizard-discovery has already occurred and False otherwise.

    is_registered

    You may notice from the example above that the last line in the sample code is:

      This sort of thing should look very familiar, as a similar approach is used for cms_apps, template tags and even Django’s admin.

      Calling the wizard pool’s register method will register the provided wizard into the pool, unless there is already a wizard of the same module and class name. In this case, the register method will raise a cms.wizards.wizard_pool.AlreadyRegisteredException.

      unregister

      It may be useful to unregister wizards that have already been registered with the pool. To do this, simply call:

      The value returned will be a Boolean: True if a wizard was successfully unregistered or False otherwise.

      get_entry

      If you would like to get a reference to a specific wizard in the pool, just call get_entry() as follows:

      1. wizard = wizard_pool.get_entry(my_app_wizard)

      is useful if it is required to have a list of all registered wizards. Typically, this is used to iterate over them all. Note that they will be returned in the order of their weight: smallest numbers for weight are returned first.: