سؤال

I try to achieve the following:

<img src="/static/teammembers/some_name">

but if I write <img src="{% static 'teammembers/{{ image }} %}"> in the template,
then the rendered output is

<img src="/static/teammembers/{{ image }}">

what am I doing wrong?

EDIT:

In my case the solution for this question does not work, since I use an automatic cachebuster (django-cachebuster).

هل كانت مفيدة؟

المحلول

You can use with with an add template filter as suggested here:

{% with 'teammembers/'|add:image as image_static %}
    <img src="{% static image_static %}">
{% endwith %}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top