Browsing index pages (3 articles)
↧
Django template tags within a hyperlink
In my .html file, I have this code:<ul> {% for file in files %}<li><a href="{% static 'notebooks/<**Part that I want to reference dynamically**>' %}">{{ file...
View ArticleAnswer by knbk for Django template tags within a hyperlink
You can use variables in your tags, though you can't interpolate them into strings like you're trying to do. You could add the path, with notebooks/, to files and use that in {% static %}:# Viewdef...
View ArticleAnswer by doniyor for Django template tags within a hyperlink
{% for file in files %} {% with file_with_path='notebooks/'|add:file %}<li><a href="{% static file_with_path %}">{{ file }}</a></li> {% endwith %} {% endfor %}
View Article
Browsing index pages (3 articles)