Python 摇尾如何渲染图像:无法识别的操作:原始图像
如何从Productpage.html中的Python 摇尾如何渲染图像:无法识别的操作:原始图像,python,django,image,wagtail,Python,Django,Image,Wagtail,如何从Productpage.html中的ForeignKey('wagtailimages.image')呈现图像 我当前收到错误信息: 无法识别的操作:原始 为什么这不起作用 {%image page.productImage orignal%} Productpage.html {% extends "base.html" %} {% load wagtailcore_tags wagtailimages_tags %} {% block body_class %}templat
ForeignKey('wagtailimages.image')
呈现图像
我当前收到错误信息:
无法识别的操作:原始
为什么这不起作用
{%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 %}
正如前面提到的,您的代码中有一个输入错误
{%image page.productImage orignal%}
应该是{%image page.productImage original%}
(在original
中缺少i
)
每当你遇到这样一个奇怪的错误,你无法找出它,并且没有任何SO或谷歌答案,很可能是打字错误 正如前面提到的,您的代码中有一个输入错误
{%image page.productImage orignal%}
应该是{%image page.productImage original%}
(在original
中缺少i
)
每当你遇到这样一个奇怪的错误,你无法找出它,并且没有任何SO或谷歌答案,很可能是打字错误 您的代码中有一个输入错误:
orignal
应该是original
。这是唯一一个代码片段,它(间接地)启发了我,在模板块中使用摇尾图像时,您的代码中有一个输入错误:orignal
应该是original
。这是唯一一个代码片段,它(间接地)启发了我,关于在模板块中使用摇摆图像
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
]