我可以在另一个可订购商品中订购一个吗?

时间:2020-07-09 09:53:28

标签: python html django wagtail

我有这个设置,可订购的设备允许我添加多张显示pdf文档的卡片。但是,有没有一种方法可以在InLinePanel内部显示Orderable?

例如,我想说20张卡片,但是在这些卡片中,pdf的数量范围为1到10。我想这样做是因为它使pdf易于查找并且非常灵活。


class ArchitectPage(Page):
    search_fields = Page.search_fields + [

    ]  # these are if adding a search to the website

    # content tab panels
    content_panels = Page.content_panels + [
        MultiFieldPanel(
            [InlinePanel('architect_pdf', max_num=20, min_num=0, label="architect doc")],
            heading="architect pdf"
        ),
    ]

    # what to call the panels on wagtail
    edit_handler = TabbedInterface([
        ObjectList(content_panels, heading='Content'),
        ObjectList(Page.promote_panels, heading='SEO'),
        ObjectList(Page.settings_panels, heading='Settings', classname='settings'),
        # classname settings adds the cog
    ])


class ArchitectDownloads(Orderable):
    page = ParentalKey(ArchitectPage, on_delete=models.CASCADE, related_name='architect_pdf')
    architect_pdf = models.ForeignKey(
        'wagtaildocs.Document',
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='+'
    )
    image = models.ForeignKey(
        'wagtailimages.Image',
        null=True,
        blank=True,
        on_delete=models.CASCADE,
        related_name='+'
    )
    caption = models.CharField(blank=True, max_length=250)

    panels = [
        ImageChooserPanel('image'),
        FieldPanel('caption'),
        DocumentChooserPanel('architect_pdf'),
    ]
{% for download in page.architect_pdf.all %} 

            <div class="document line-up-card">
                <div class="w3-card-4 w3-margin w3-white" data-aos="fade-down">


                    {% image download.image fill-150x150-c100 %}
                    {% with doc=download.architect_pdf %} 

                        <div class="w3-container">
                            {{ doc.title }}
                        </div>

                    {% endwith %}

                  <hr>
                    <p id="caption">{{ download.caption }}</p>

                    {% with doc=download.architect_pdf %}

                        <div class="download">
                            <a href="{{ doc.url }}" class="smooth-over-button noDecoration">
                                <i class="fa fa-download"></i>
                                <p class="btn-txt">PDF</p>
                            </a>

                        </div>

                    {% endwith %}


                </div>
            </div>

{% endfor %}

card view

1 个答案:

答案 0 :(得分:0)

这似乎还没有添加到w中,但是Kalob Taulein在看起来相同的替代品上做了很棒的教程。

这是实现它们所需的2个教程。

How to add basic Streamfield to you

How to Use ListBlocks in Wagtail CMS to Create Repeating StreamField Content