Allows using StructBlock and ListBlock as model fields
Project description
wagtail-block-fields
Use Wagtail's StructBlock and ListBlock as standalone model fields.
Just like StreamField wraps StreamBlock, this package provides:
StructField- wraps aStructBlockListField- wraps aListBlock
Installation
pip install wagtail-block-fields
Usage
StructField
from wagtail.blocks import CharBlock, StructBlock
from wagtail_block_fields import StructField
class AddressBlock(StructBlock):
street = CharBlock()
city = CharBlock()
postal_code = CharBlock()
class MyPage(Page):
address = StructField(AddressBlock())
contact = StructField([
('email', CharBlock()),
('phone', CharBlock()),
])
ListField
from wagtail.blocks import CharBlock
from wagtail_block_fields import ListField
class MyPage(Page):
tags = ListField(CharBlock())
categories = ListField(CharBlock(), min_num=1, max_num=5)
addresses = ListField(AddressBlock())
In templates
<p>{{ page.address.street }}, {{ page.address.city }}</p>
<ul>
{% for tag in page.tags %}
<li>{{ tag }}</li>
{% endfor %}
</ul>
{% for address in page.addresses %}
<p>{{ address.street }}, {{ address.city }}</p>
{% endfor %}
Why?
Sometimes you need structured JSON data in a single field without the complexity of StreamField. These fields:
- Store data as JSON in a single database column
- Provide full Wagtail admin editing UI
- Support validation, search indexing, and reference extraction
- Work with migrations just like StreamField
License
MIT
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wagtail_block_fields-0.2.0.tar.gz.
File metadata
- Download URL: wagtail_block_fields-0.2.0.tar.gz
- Upload date:
- Size: 46.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ea3c21240cc687b5f44b787fd6f3457e14fa36003fe0e607d35b01a7dddaf97
|
|
| MD5 |
ac44ba3d510b006b0b56a9841ce4f124
|
|
| BLAKE2b-256 |
68ae288f8e07ac76fc5e2546419d35fb7b1990d3db885330dec2342d3af86ff8
|
Provenance
The following attestation bundles were made for wagtail_block_fields-0.2.0.tar.gz:
Publisher:
publish.yml on joeyjurjens/wagtail-block-fields
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
wagtail_block_fields-0.2.0.tar.gz -
Subject digest:
3ea3c21240cc687b5f44b787fd6f3457e14fa36003fe0e607d35b01a7dddaf97 - Sigstore transparency entry: 767903400
- Sigstore integration time:
-
Permalink:
joeyjurjens/wagtail-block-fields@4cf38e1132a901508e0a34be07bc3de9ceda4052 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/joeyjurjens
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4cf38e1132a901508e0a34be07bc3de9ceda4052 -
Trigger Event:
release
-
Statement type:
File details
Details for the file wagtail_block_fields-0.2.0-py3-none-any.whl.
File metadata
- Download URL: wagtail_block_fields-0.2.0-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
218be2ab13d0d6c4313790b26b2e54c6c50770a170abfc5c328cc9ee81ae76ce
|
|
| MD5 |
4bdbfcb9fddd1db311e973bbef2b3e15
|
|
| BLAKE2b-256 |
9d016fb38d327059bcc598ab81ef800dd19dbe3b2b9b76f0d9626e3b6aabdda1
|
Provenance
The following attestation bundles were made for wagtail_block_fields-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on joeyjurjens/wagtail-block-fields
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
wagtail_block_fields-0.2.0-py3-none-any.whl -
Subject digest:
218be2ab13d0d6c4313790b26b2e54c6c50770a170abfc5c328cc9ee81ae76ce - Sigstore transparency entry: 767903442
- Sigstore integration time:
-
Permalink:
joeyjurjens/wagtail-block-fields@4cf38e1132a901508e0a34be07bc3de9ceda4052 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/joeyjurjens
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4cf38e1132a901508e0a34be07bc3de9ceda4052 -
Trigger Event:
release
-
Statement type: