Вопрос

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