Django urldecode在模板文件中 [英] Django urldecode in template file
本文介绍了Django urldecode在模板文件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
urldecode
有什么办法吗? 我想将 app%20llc
转换为 app llc
解决方案
您可以创建一个简单的 custom filter around urllib.unquote
例如:
from django.template.defaultfilters import stringfilter
from urllib import unquote
@stringfilter
def unquote_raw(value) :
return unquote(value)
现在你可以在你的dj ango模板文件:
{{raw | unquote_raw}}
is there any way do the urldecode
in Django template file?
Just opposite to urlencode or escape
I want to convert app%20llc
to app llc
解决方案
You could create a simple custom filter around urllib.unquote
For instance:
from django.template.defaultfilters import stringfilter
from urllib import unquote
@stringfilter
def unquote_raw(value):
return unquote(value)
and now you can have this in your django template file:
{{ raw|unquote_raw }}
这篇关于Django urldecode在模板文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文