Search code examples
pythonpluginsdjango-cms

Django CMS: Set default placeholder value when page was created


I'm new in Django CMS. When I create my new page, I have to choose placeholders and plugins. Is possible to set all default plugins at post_save? Thanks.


Solution

  • You can do this with settings by setting the default_plugins attribute of the placeholder in CMS_PLACEHOLDER_CONF;

    CMS_PLACEHOLDER_CONF = {
        'content': {
            'plugins': ['TextPlugin', 'PicturePlugin'],
            'name': gettext("Content"),
            'language_fallback': True,
            'default_plugins': [
                {
                    'plugin_type': 'TextPlugin',
                    'values': {
                        'body':'<p>Default text plugin for the `content` placeholder...</p>',
                    },
                },
            ],
        },
    }
    

    Then any page with the content placeholder will be created with a TextPlugin containing <p>Default text plugin for thecontentplaceholder...</p>

    The docs for this can be found here; http://docs.django-cms.org/en/latest/reference/configuration.html#cms-placeholder-conf