[英]Django Filer getting 'thumbnail' is not a valid tag library error to do with ImageChop
[英]Django filer thumbnail's path
我基於 AbstractUser model 創建了一個自定義用戶 model。 如何找到要在模板文件中使用的縮略圖的正確路徑?
class User(AbstractUser):
photo = FilerImageField(related_name='profile_photo', null=True, on_delete=models.SET_NULL)
{% extends "base.html" %}
{% load thumbnail %}
{% block content %}
{% thumbnail user.photo 250x250 crop %}
{% thumbnail user.photo 250x250 crop %} #
{% endblock %}
TemplateSyntaxError
Exception Value:
Variable 'user.photo' is an invalid source.
如果您使用的是 sorl-thumbnail,請在模板中嘗試這個
{% thumbnail user.photo "250x250" crop="center" as im %}
<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}">
{% endthumbnail %}
如果您使用簡單的縮略圖,請在 template.html 中使用以下代碼
{% load thumbnail %}
<img src="{% thumbnail profile.photo 50x50 crop %}" alt="" />
如果您使用的是 django-filer,則不需要在模板縮略圖標簽中
{% load thumbnail %}
{% thumbnail user.photo 250x250 crop %}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.