question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Block names of StructBlock are not properly displayed

See original GitHub issue

v1.0b2

The Wagtail code:

class HomePage(Page):
    body = StreamField([
        ('heading', blocks.CharBlock(classname="full")),
        ('carousel', ListBlock(
            StructBlock([
                ('image', ImageChooserBlock()),
                ('page', PageChooserBlock()),
                ('quotation', TextBlock()),
            ]), icon='cogs', template='shop/blocks/carousel.html')),
    ])

I get the following editing interface:

streamfield_label

Note that the image and quotation block names are not displayed as block page does.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
iSquatchcommented, Oct 1, 2016

This topic is over a year old, but I can’t figure out how to get the below suggestion to work…

This is failing because the PageChooserBlock only returns a plain Page instance, which doesn’t include the additional intro/body fields from ItemPage. You can convert the Page instance to an instance of ItemPage (at the cost of an extra database query) by accessing {{ item.page.specific }}.

{% for item in self.products_a %}
  <div class="column">
    <img class="thumbnail" src="http://placehold.it/300x400">
    <h5>{{ item }}</h5>
    <p>{{ item.page.specific.price }}</p>
    <p>{{ item.page.price}}</p>
    <a href="#" class="button expanded">Buy</a>
  </div>
{% endfor %}

I’m not having any luck trying to get the Product page properties. The only property I can access is{{ item }}. What do I need to do to access the specific page properties?

Any tips on this would be greatly appreciated.

0reactions
gasmancommented, Oct 2, 2016

Hi @DevinCalado - please use the Wagtail support Google group for support queries.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Django Wagtail TableBlock not displaying correctly
I managed to set up the model and the block correctly but when the html is rendered, i'm not getting a table but...
Read more >
How to use StreamField for mixed content
Placing a StructBlock's list of child blocks inside a StreamField definition can often be hard to read, and makes it difficult for the...
Read more >
Freeform page content using StreamField
The parameter to StreamField is a list of (name, block_type) tuples. 'name' is used to identify the block type within templates and the...
Read more >
Access a streamfield block's index within its template
My question is whether anyone would be aware of a way to get the current index of a template based 'for loop' that...
Read more >
Creating and Editing Wagtail Components - CFPB
In Wagtail parlance, these are called "StreamField blocks"* (or just "blocks"). ... label is not set, Wagtail will generate one from the name...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found