urlencode过滤器在django模板中不起作用(urlencode filter is not working in django templates)

编程入门 行业动态 更新时间:2024-10-27 10:22:13
urlencode过滤器在django模板中不起作用(urlencode filter is not working in django templates)

我在Apache下使用django。 当我在django模板中使用urlencode时,它根本没有编写像这样的{{value|urlencode}}这里是我完整的锚标签

<a href="/mysite/comment/{{i.comment_id|urlencode}}">Comment</a>

有人可以帮助吗? 有什么办法摆脱这个?

在此先感谢 - Vikram

I am using django under Apache. When I use urlencode in django template, its not at all enoding some thing like this {{value|urlencode}} Here is my complete anchor tag

<a href="/mysite/comment/{{i.comment_id|urlencode}}">Comment</a>

Can some one help on this? Is there any way to get rid of this?

Thanks in advance - Vikram

最满意答案

urlencode过滤器仅对网址中不安全的字符进行编码。 如果你想编码所有的字符,那么你将需要编写或找到一个不同的过滤器。

The urlencode filter only encodes characters that are unsafe to have in a URL. If you want to encode all characters then you will need to write or find a different filter for that.

更多推荐

本文发布于:2023-08-07 23:11:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1466377.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:过滤器   中不   模板   django   urlencode

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!