Skip to main content

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

wagtailblock-register-1.7.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wagtailblock_register-1.7-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file wagtailblock-register-1.7.tar.gz.

File metadata

  • Download URL: wagtailblock-register-1.7.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.0.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for wagtailblock-register-1.7.tar.gz
Algorithm Hash digest
SHA256 9f8386677201b46db0e02270f19535f513c9a0e632dc58397c6759d4ccadc4fb
MD5 b07a1eb8a9854a7e7d5179e40b6d9df1
BLAKE2b-256 fea9439513566f548da82df800b26ad2a8e45dc0817136f7474f66579749427d

See more details on using hashes here.

File details

Details for the file wagtailblock_register-1.7-py3-none-any.whl.

File metadata

  • Download URL: wagtailblock_register-1.7-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.0.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for wagtailblock_register-1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 5fcd3069f45bfc4711fa8bf4a3c31e90e3a940a074f3a01dce1c742fe22a4cbd
MD5 83fa74306175bd8354a0fadd505f0ea5
BLAKE2b-256 f328af314d7e78f660fe2a734b48c3a6b5f8aa21a52abe60a5e188dd33c227f1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page