Wagtail 如何渲染图像:无法识别的操作:原始

Wagtail how to render an image: Unrecognised operation: orignal

如何从 Productpage.html 中的 ForeignKey('wagtailimages.Image') 渲染图像?

我目前收到错误:

Unrecognised operation: orignal

为什么这不起作用?:

{% image page.productImage orignal %}

Productpage.html

{% extends "base.html" %}  
{% load wagtailcore_tags wagtailimages_tags %}   
{% block body_class %}template-productspage{% endblock %}   
{% block content %}
    <h1>{{ page.title }}</h1>
    <p class="meta">{{ page.count }}</p>    
    <div class="intro">{{ page.intro }}</div>
    {{ page.description|richtext }}

      {% image page.productImage orignal %}

      <img class="" src="{{ productImage.url }}" style="width:100%;" alt="Card image">

    <p><a href="{{ page.get_parent.url }}">Return to blog</a></p>

{% endblock %}

Products/models.py

  from django.db import models

from modelcluster.fields import ParentalKey
from wagtail.core.models import Page, Orderable
from wagtail.core.fields import RichTextField
from wagtail.admin.edit_handlers import FieldPanel, InlinePanel
from wagtail.images.edit_handlers import ImageChooserPanel
from wagtail.search import index
from wagtail.images.models import Rendition

class ProductPage(Page):
    intro = models.CharField(max_length=250)
    count = models.IntegerField(default=1)
    description = RichTextField(blank=True)
    productImage = models.ForeignKey(
    'wagtailimages.Image', null=True, on_delete=models.CASCADE, related_name='+'
    )

    search_fields = Page.search_fields + [
        index.SearchField('intro'),
        index.SearchField('description'),
    ]

    content_panels = Page.content_panels + [
        FieldPanel('intro'),
        FieldPanel('count'),
        FieldPanel('description', classname="full"),
        ImageChooserPanel('productImage'),                           # ERRORS OUT IN HTML
        #InlinePanel('gallery_images', label="Gallery images"),   # MULTPIPLE IMAGES
    ]

所述,您的代码中有一个错字。

{% image page.productImage orignal %} 应该是 {% image page.productImage original %}(在 original 中缺少一个 i

每当您 运行 遇到像这样的奇怪错误并且您无法弄清楚,并且没有任何 SO 或 Google 答案时,很可能是打字错误。