为什么 django-stdimage 不在我的 html 模板中呈现?

why django-stdimage not rendering in my html template?

为什么图像没有在我的 html 模板中呈现?这是我的代码:

#models.py

from django.db import models
from PIL import Image
from stdimage import StdImageField

class Contact(models.Model):
    name = models.CharField(max_length=200)
    image = StdImageField(upload_to="contact/images/",variations={'thumbnail':(640,480)})

#settings.py 在我的应用程序中添加了 'stdimage'

#html

{{myimagefield.thumbnail}} 

我找到我错的地方了。我需要在模板中使用 {{contact.image.thumbnail}} 而不是 {{myimagefield.thumbnail}}。其中联系人是我的模型 class 名称和图像是我的字段名称。

重要说明: 变体添加到正在上传的图像中,而不是替换。请参阅 docs 2 顶部的第 4 个要点。