Writing your own CMS plugin

Django CMS comes with a lot of content plugins that can be used in template placeholders, such as the text, flash, picture, and Google map plugins. However, for more structured and better styled content, you will need your own custom plugins, which are not too difficult to implement. In this recipe, we will see how to create a new plugin and have a custom layout for its data, depending on the chosen template of the page.

Getting ready

Let's create an editorial app and mention it in the INSTALLED_APPS setting. Also, we will need the cms/magazine.html template that was created and mentioned in the CMS_TEMPLATES setting; you can simply duplicate the cms/default.html template for this.

How to do it...

To create the EditorialContent ...

Get Web Development with Django Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.