1

The core problem is that handling of wagtail RichTextField and StreamField is radically different in the templates.

I'm trying to accomplish something similar to the following:

{% with post=post.specific %}
    {% if post.content_type == 'streamfield' %}
        {% include_block post.body %}
    {% else %}
        {{ post.body|richtext }}
    {% endif %}
{% endwith %}
NarūnasK
  • 4,564
  • 8
  • 50
  • 76
  • This sounds like an [X-Y problem](http://mywiki.wooledge.org/XyProblem) to me. How have you reached a situation where a template doesn't know what type of content it's working with? – gasman Jan 16 '18 at 12:05
  • 1
    @gasman I've got here by following [Getting started](http://docs.wagtail.io/en/v1.13.1/getting_started/tutorial.html) guide. `BlogIndexPage` there gather all its children and put them in the `blogpages` ctx attribute, then in the template they use `{{ post.body|richtext }}` to display all the posts. It works in this simple example, but we all know that in `wagtail` all parent can have a child of any type, therefore some posts might be published using `StreamField` while others `RichTextField` and here we have a problem prescribed in the question. – NarūnasK Jan 16 '18 at 12:18
  • {{ post.get_verbose_name }} – nmcilree Sep 02 '21 at 13:39

0 Answers0