Wagtail/Django: Как передать объект модели Page в качестве значения по умолчанию для блока streamfield?

Как я могу передать выбранное пользователем значение для объекта background_color, который находится в моем классе PostPage Page, как значение по умолчанию для другого ColorField, который находится в моих блоках streamfield?

class PostPage(Page):
    # The user selected value for background_color is the object that I'm trying to pass as a default for a streamfield block.
    background_color = ColorField(default="#000000")

    # streamfield in question
    blog_builder = StreamField(BlogFeatures(), blank=True)

    content_panels = Page.content_panels + [
        NativeColorPanel('background_color'),
        StreamFieldPanel("blog_builder"),
    ]
    edit_handler = TabbedInterface([
        ObjectList(content_panels, heading="Content"),
    ])

Вот мой класс Streamfield, который использует StreamBlock:

class BlogFeatures(StreamBlock):

    simple_list = SimpleList()  

Я использую Structblock, чтобы помочь достичь своих целей в стриминге:


class SimpleList(StructBlock):
    ...
    # how can I set the default value of this background_color to match the user selected value from the Page Model called PostPage.
    background_color = NativeColorBlock(default="#ffffff")
    ...

    
Вернуться на верх