Skip to main content
Python Software Foundation 20th Year Anniversary Fundraiser  Donate today!

Wagtail Content Stream provides a StreamField of standard content types.

Project description

Wagtail Content Stream

An abstract Django model with a Wagtail StreamField named body with multiple blocks I use on a regular basis. It's opinioned: very little HTML is allowed in the text block, forcing authors to create structured data. The following blocks are included in the StreamBlock, ContentStreamBlock:

  • Heading
  • Paragraph
  • Captioned Image
  • Embed
  • Table
  • Code Block

A secondary StreamBlock, ContentStreamBlockWithRawCode, also provides an additional block for injecting HTML, JS, and CSS code. Use with care, as this can really blow up your markup and is a potential code injection point!

Three pages types are provided out-of-the-box.

Example Usage

You will need to add wagtailcodeblock to your INSTALLED_APPS Django setting.

Basic Usage: a Title Field and Content Stream

First, create a page type in your

from wagtailcontentstream.models import ContentStreamPage, SectionContentStreamPage, ContentStreamPageWithRawCode

class StandardPage(ContentStreamPage):

class SectionStandardPage(SectionContentStreamPage):

class StandardPageWithRawCode(ContentStreamPageWithRawCode):

Then in your template:

{% load wagtailcore_tags %}

<h2>{{ page.title }}</h2>
{% include_block page.body %}

Extended Usage: Adding More Fields

from django.conf import settings
from django.db import models
from wagtail.wagtailadmin.edit_handlers import FieldPanel
from wagtailcontentstream.models import ContentStreamPage

class StandardPage(ContentStreamPage):
    date = models.DateField("Post Date")
    authors = models.ManyToManyField(settings.AUTH_USER_MODEL)

    content_panels = [
    ] + ContentStreamPage.content_panels

Change Log


  • Added ContentStreamPageWithRawCode and ContentStreamBlockWithRawCode for injecting raw code into pages.


  • Wagtail 2.0 compatibility.


  • Add support for alignment and credit of CaptionedImageBlock.


  • Add a StreamBlock with sections.


  • Help text and a bug fix for Section StreamBlocks.


  • Improve block templates.


  • Add Documents as a block type.


  • Initial release.


Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for wagtailcontentstream, version 0.4.0
Filename, size File type Python version Upload date Hashes
Filename, size wagtailcontentstream-0.4.0-py3-none-any.whl (6.1 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size wagtailcontentstream-0.4.0.tar.gz (4.6 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page