0

I am learning Wagtail and Django. And I got an issue with the following code.

Main goal is to have separate block templates for carousel items and carousel itself. When I start this code in Wagtail with added carousel items, I see that block template carousel_main.html was parsed by Wagtail but block template carousel_item.html was not. Most probably I am doing something wrong but I cannot seem to figure it out.

    class CarouselBlock(blocks.StructBlock):
        image = ImageChooserBlock()
        text = blocks.RichTextBlock(blank=True)

        class Meta:
            template = 'carousel_item.html'

    class Carousel(blocks.StructBlock):
        carousel = blocks.ListBlock(CarouselBlock(),blank = True)

        class Meta:
            template = 'carousel_main.html'

    class HomePage(Page):
        carousel_field = StreamField(
            [
                ('carousel',Carousel()),

            ],blank = True
        )

        content_panels = Page.content_panels + [
            StreamFieldPanel('carousel_field')
        ]

1 Answer 1

1

First, have you already created carousel_main.html and carousel_item.html at the top of your templates directory? (You can place it under the top of your home/templates if you'd like.)

If you're still seeing the welcome page when you use manage.py runserver, you have to change the contents of your home_page.html template as described in the Wagtail tutorial.

Second, have you already used the include_block template tag in home_page.html and carousel_main.html? There are step-by-step instructions on how to use it in the Wagtail docs.

Other than that, you're off to a great start.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.