Dominic M.
Dominic M.

Reputation: 913

Wagtail how to render an image: Unrecognised operation: orignal

How do I render an image from a ForeignKey('wagtailimages.Image') inside Productpage.html?

I'm currently receiving the error:

Unrecognised operation: orignal

Why is this not working?:

{% 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
    ]

Upvotes: 0

Views: 466

Answers (1)

Kalob Taulien
Kalob Taulien

Reputation: 1918

As mentioned by @solarissmoke You just have a typo in your code.

{% image page.productImage orignal %} should be {% image page.productImage original %} (missing an i in original)

Whenever you run into a strange error like this and you can't figure it out, and there aren't any SO or Google answers, chances are it's a typo.

Upvotes: 2

Related Questions