我是 django 新手,尝试在对变量和字符串进行 urlencode 之前将两者连接起来。
我已经有 #{profile.name|urlencode}
但需要类似 #{urlencode('string' + profile.name)}
非常感谢任何帮助
最佳答案
使用 add 将 string
与 profile.name
连接起来并为其分配变量:
{% with name="string"|add:profile.name %}
{{ name|urlencode }}
{% endwith %}
关于python - 在 django 中的 urlencode 之前连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23086991/