Django Template Language - getting url encoded values

柔情痞子 提交于 2019-12-02 12:53:48

You can't have a variable in the static tag, that's why you see these %7B%7B in your HTML output.

You can however do this:

{% load static %}
<img src="{% get_static_prefix %}img/category/{{category.category|lower|slugify}}.jpg">

First of all - shouldn't that image be served from media files? Static files are not designed to be connected with models, that's what media files are for.

Secondly - you can't use variables syntax inside other tags in django. Unless tag is designed to take some parameters, you can't pass them into.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!