Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make a Wagtail Streamfield not required?

In the model below I want to make the bottom_content field in its entirety not required. How can I do this?

class ServicePage(Page):
  top_content = StreamField(default_blocks + [
    ('two_columns', TwoColumnBlock()),
    ('three_columns', ThreeColumnBlock()),
  ])
  bottom_content = StreamField(default_blocks + [
    ('two_columns', TwoColumnBlock()),
    ('three_columns', ThreeColumnBlock()),
  ])

  search_fields = Page.search_fields + [
    index.SearchField('top_content'),
    index.SearchField('bottom_content'),
  ]

  content_panels = Page.content_panels + [
    StreamFieldPanel('top_content'),
    StreamFieldPanel('bottom_content'),
    InlinePanel('service_package', label='Packages')
  ]
like image 256
NVN Avatar asked Nov 16 '17 18:11

NVN


1 Answers

StreamField also accepts an optional keyword argument blank, defaulting to false; when this is false, at least one block must be provided for the field to be considered valid.

from: - http://docs.wagtail.io/en/latest/topics/streamfield.html

like image 148
rollinger Avatar answered Nov 12 '22 09:11

rollinger