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 models.py
:
from wagtailcontentstream.models import ContentStreamPage, SectionContentStreamPage, ContentStreamPageWithRawCode
class StandardPage(ContentStreamPage):
pass
class SectionStandardPage(SectionContentStreamPage):
pass
class StandardPageWithRawCode(ContentStreamPageWithRawCode):
pass
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 = [
FieldPanel('date'),
FieldPanel('authors'),
] + ContentStreamPage.content_panels
Change Log
0.4
- Added ContentStreamPageWithRawCode and ContentStreamBlockWithRawCode for injecting raw code into pages.
0.3
- Wagtail 2.0 compatibility.
0.3.1
- Add support for alignment and credit of CaptionedImageBlock.
0.2
- Add a StreamBlock with sections.
0.2.1
- Help text and a bug fix for Section StreamBlocks.
0.2.2
- Improve block templates.
0.2.3
- Add Documents as a block type.
0.1
- Initial release.
Contributors
- Timothy Allen (https://github.com/FlipperPA)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for wagtailcontentstream-0.4.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 17812d563657d815e5db780b10dd3cb75df3af28f17f74dd91057bdbd96b2f66 |
|
MD5 | 310ec19890898a7293cbb6984775163e |
|
BLAKE2b-256 | 4c762fe154f21037d5e1405bd838425cad1745185b6e86351e7c4a82a860636e |
Hashes for wagtailcontentstream-0.4.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 645a242218c85c89e9c846c47c0e0769f09e1d004551c4ad6e6825c90a278396 |
|
MD5 | cdc00b52dd8f1dfcc4a30d2366d87805 |
|
BLAKE2b-256 | 97fe4cfe61b8fda845afc7f4f7c995dd36ea0bb83cc474bdb85383e6038bf299 |