Search code examples
pythondjangodjango-cms

DjangoCMS: how to auto-add default plugins in placeholders


I have a few placeholders in my DjangoCMS template (par example, header, contetent and footer). I want to automatically populate any newly-created pages with default items: header placeholder with header plugin and footer placeholder with footer plugin.

How can it be done?


Solution

  • This can be done using the CMS_PLACEHOLDER_CONF setting, specifically, the default_plugins option:

    CMS_PLACEHOLDER_CONF = {
        'footer': {
            'name': "Footer",
            'default_plugins':[
                {
                    'plugin_type':'FooterPlugin',
                    'values':{
                        'body':'<p>This is the footer</p>'
                    },
                },
            ]
        },
    }
    

    This assumes that your FooterPlugin has a field body that allows HTML content.