Register wagtailblocks with a simple decorator
Project description
Wagtailblock Register
Usage
Add in settings.py.
# Default WAGTAILBLOCK_COLLECTOR = "blocks"
WAGTAILBLOCK_COLLECTOR = "itemblocks"
String in WAGTAILBLOCK_COLLECTOR
is a file. Default collector file is blocks.py.
Wagtailblock register will search for the file.
Add block to collector
Above each block in the collectors file add @register_block
Example:
from wagtailblock_register import register_block
from wagtail.core import blocks
from wagtail.images.blocks import ImageChooserBlock
@register_block
class ImageTextBlock(blocks.StructBlock):
...
Call all blocks in models.py
Example:
from wagtail.core.models import Page
from wagtail.core.fields import StreamField
from wagtailblock_register import call_blocks
class ContentPage(Page):
body = StreamField(call_blocks(), null=True)
...
Group blocks
Add list_group
with a group name to the block.
This property will group your blocks in diffrent groups. The block will be in the group you defined. Default group is default
.
This property is usefull if you want to use multiple streamfields.
Example:
from wagtailblock_register import register_block
from wagtail.core import blocks
from wagtail.images.blocks import ImageChooserBlock
@register_block
class ImageTextBlock(blocks.StructBlock):
list_group = "first"
...
Project details
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
Close
Hashes for wagtailblock-register-1.6.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca22cd1f3b22150ab175895c6d446a4623b6cf5286c80043e86a6551062da292 |
|
MD5 | 7359018c021c8b134a8edb15a295be32 |
|
BLAKE2b-256 | 5f097b3864ab50cb79a34bc5013fcbcf12b14d0b23b9650d68975b48fc3feb79 |
Close
Hashes for wagtailblock_register-1.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc843b68a08a0a1f73531fb0db6aeb5fc468337ea06808bd44757511f025462d |
|
MD5 | 9e53ed9b7e817e036a46269a85c1ba1d |
|
BLAKE2b-256 | 2d04a6159e6381f35c43df0f852f5a47808455f892d1a092936b415f12024fef |