Как мне сделать изображение из ForeignKey('wagtailimages.Image')
внутри Productpage.html?
В настоящее время я получаю сообщение об ошибке:
Нераспознанная операция: 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
]