Back-End/Wagtail, Django

Wagtail StreamField Options

Vicapor 2021. 12. 2. 00:58

1. Models.py

    from wagtail.core import blocks as streamfield_blocks
    
    
    content = StreamField(
        [
			...
            ("char_block", streamfield_blocks.CharBlock(
                required=True,
                help_text="Oh wow this is help text!!",
                min_length=10,
                max_length=50,
                template="streams/char_block.html"
            ))
        ],
    )

 

 

2. templates

 

streams/char_block.html

<div class="container">
    <div class="row">
        <col-sm-10 class="offset-sm-1">
            {{ self }}
        </col-sm-10>
    </div>
</div>