0

I have a StructBlock like this:

class JumbotronBlock(blocks.StructBlock):
fullwidth= blocks.BooleanBlock(requried=False, help_text="Full width of the viewport")
heading= blocks.CharBlock(required=True, help_text="Heading for the jumbotron")
lead= blocks.CharBlock(required= False, help_text= "Lead text for Jumbotron")
link= LinkBlock(required=False)
bg_image= ImageChooserBlock(required=False)
bg_color= blocks.CharBlock(required=False, help_text="Hex value for background color")
classes= blocks.CharBlock(required=False, help_text="CSS classes for jumbotron")
styles= blocks.CharBlock(required=False, help_text="Custom style definitions for jumbotron")

class Meta:
    template="streams/jumbotron_block.html"
    icon= "placeholder"
    label= "Jumbotron"

And My HomePage Class model is this:

class HomePage(Page):
template= "home/home_page.html"
header= Jumbotron()

body =  StreamField([
    ('Richtext', RichTextBlock()),
    ('CTA', CTABlock()),
    ('Section', SectionBlock()),
    ])

content_panels = Page.content_panels + [
    ??which panel here??('header'),
    StreamFieldPanel('body'),
    ]

Which panel should I use to add the Jumbotron to the edit panels? Thanks.

shiv
  • 9
  • 3

1 Answers1

2

StructBlock is not usable as a model field - it is only valid inside a StreamField. You need to define the fields of your jumbotron block as Django model fields within your HomePage model, and - if you want to group them together visually in the edit view - place them in a MultiFieldPanel.

gasman
  • 23,691
  • 1
  • 38
  • 56
  • Thanks. This must be the reason why I can't find it included independently in the docs. I ll have a go and come back later to select your answer as a solution. – shiv Dec 17 '19 at 14:25