문제

when I use external images it works fine:

{% thumbnail "http://127.0.0.1:8000/media/files/logo.png" "40x40" crop="80% top" as im %}
    <img src="{{ im.url }}">
{% endthumbnail %}

But when I change first line to:

{% thumbnail "http://127.0.0.1:8000/media/{{ field.value }}" "40x40" crop="80% top" as im %}

And {{ field.value }} is string files/logo.png for sure, it doesn't work any more. Is it possible to use Django tags inside thumbnail template tag and how?

도움이 되었습니까?

해결책

It seems like thumbnail tag interpret {{ field.value }} literally.

How about using add filter?

{% thumbnail "http://127.0.0.1:8000/media/"|add:field.value "40x40" ... %}

Check whether field.value is a valid string.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top