Reputation: 21
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')
]
Upvotes: 0
Views: 1227
Reputation: 303
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.
Upvotes: 1