An alternative implementation of the Wagtail StreamField.
Project description
Wagtail AlternateStreamField
This project provides an alternate implementation of Wagtail's StreamField. This was created to resolve issues with performance for more complicated block structures.
Basic Installation and Usage
To install use pip:
pip install wagtail-altstreamfield
Add "altstreamfield" to your Django Project's INSTALLED_APPS
list.
Create some custom blocks and a wagtail.core.models.Page
subclass like the following:
#filename: [yourapp]/models.py
from django.db import models
from wagtail.core.models import Page
from wagtail.admin.edit_handlers import FieldPanel, StreamFieldPanel
from altstreamfield.edit_handlers import AltStreamFieldPanel
from altstreamfield.fields import AltStreamField
from altstreamfield.blocks import (
StreamBlock,
StructBlock,
BooleanField,
CharField,
ChoiceField,
DocumentChooserField,
ImageChooserField,
IntegerField,
RichTextField,
StreamBlockField,
TextField,
)
# Create some custom blocks
HEADING_TYPE_CHOICES = (
('h1', 'H1'),
('h2', 'H2'),
('h3', 'H3'),
('h4', 'H4'),
('h5', 'H5'),
('h6', 'H6'),
)
class Heading(StructBlock):
heading_type = ChoiceField(choices=HEADING_TYPE_CHOICES, required=True)
text = CharField()
class Meta:
icon = 'title'
class Paragraph(StructBlock):
text = RichTextField()
class Meta:
icon = 'pilcrow'
class DocumentLink(StructBlock):
title = CharField()
document = DocumentChooserField()
class Meta:
icon = 'doc-empty'
class SimpleStreamBlock(StreamBlock):
heading = Heading()
paragraph = Paragraph()
document = DocumentLink()
# Create your models here.
class HomePage(Page):
body = AltStreamField(SimpleStreamBlock)
content_panels = Page.content_panels + [
AltStreamFieldPanel('body', classname='full'),
]
If you are creating a large number of blocks it is a good idea to separate the blocks into a separate module or modules.
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
wagtail-altstreamfield-0.0.11.tar.gz
(603.0 kB
view hashes)
Built Distribution
Close
Hashes for wagtail-altstreamfield-0.0.11.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85c94e6985815d58104b9a04e6d1f9bfeba7daa7af8b17d14758abf72044d5b7 |
|
MD5 | 77e1f5f5761e011a13794860933ae70f |
|
BLAKE2b-256 | 4c9a7b1a3edd463d9779e2c31ed0250732ef858dfac60217bf36c13816b25ad6 |
Close
Hashes for wagtail_altstreamfield-0.0.11-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44e09f6221875d7272ed136141c6aa3a0709a3401f18eafbf22428b4484eeb6b |
|
MD5 | 00798f287d9cdb9e5c7b7ce46e6444ec |
|
BLAKE2b-256 | 40b96a6641882aa4b4d4c800254f33ffe692cd6419c75c28b3bb4fc141647937 |