[Solved]-How to concatenate a string to a number inside a template tag in Django

23👍

Try this way (added with statement with stringformat on top of yours):

{% with vid.the_id|stringformat:"s" as vid_id %}
    {% with "image-"|add:vid_id as image_id %}
         {# custom template tag to generate image #}
         {% image vid.teaser_thumbnail alt=vid.title id=image_id %}
    {% endwith %}
{% endwith %}
👤alecxe

Leave a comment