Код: Выделить всё
from wagtail.models import Page
from wagtail.fields import StreamField
from wagtail.admin.panels import FieldPanel
from strems import Blocks
class TestPage(Page):
"""Page for testing card block rendering."""
template = "strems/test.html"
cards = StreamField(
\[("cards", Blocks.cardblocks())
\],
blank=True,
null=True,
)
content_panels = Page.content_panels + \[
FieldPanel("cards"),
\]
class Meta:
verbose_name = "Test Page"
verbose_name_plural = "Test Pages"
Код: Выделить всё
class cardblocks(StructBlock):
title =CharBlock(required=True,help_text="Add text here")
cards=ListBlock(
StructBlock(
\[
("image", ImageChooserBlock(require=True)),
("title",CharBlock(required=True,max_length=23)),
("text",TextBlock(required=True,max_length=50)),
("button_page",PageChooserBlock(required=False)),
("button_url",URLBlock(required=False)),
\],
)
)
template = "strems/card_block.html"
class Meta:
icon = "placeholder"
label = "blockcards"
Код: Выделить всё
{% extends "base.html" %}
{% load wagtailcore_tags %}
{% load wagtailimages_tags%}
{% block content %}
\
\
\{{ self.title }}\
\
{% for card in self.cards %}
\
{% if card.image %}
\
[img]{{ card.image.url }}[/img]
{% endif %}
\
\{{ card.title }}\
\
{{ card.text }}\
{% if card.button_page %}
\Go to {{ card.button_page.title }}\
{% elif card.button_url %}
\Visit Link\
{% endif %}
\
\
{% endfor %}
\
\
{% endblock %}
Мой результат выглядит следующим образом:
текущий вывод
и я хочу, чтобы он выглядел так:
нужен вывод
для отображения карточек и их содержимого.
Я пробовал изменить код шаблона, но не смог решить эту проблему.
Подробнее здесь: https://stackoverflow.com/questions/793 ... ck-content
Мобильная версия