How to do it...

To create the EditorialContent plugin, follow these steps:

  1. In the models.py file of the newly created app, add the EditorialContent model extending from CMSPlugin, after which you will need to make and run migrations against the database. The EditorialContent model will have fields to store the Title, Subtitle, Description, Website, Image, Image Caption, and a CSS class:
# editorial/models.py
import osfrom django.db import modelsfrom django.utils.translation import ugettext_lazy as _from django.utils.timezone import now as tz_nowfrom cms.models import CMSPlugindef upload_to(instance, filename):    now = tz_now()    filename_base, filename_ext = os.path.splitext(filename)    return "editorial/%s%s" % ( now.strftime("%Y/%m/%Y%m%d%H%M%S"), ...

Get Django 2 Web Development Cookbook - Third 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.