is there any way do the urldecode
in Django template file?
Just opposite开发者_JAVA技巧 to urlencode or escape
I want to convert app%20llc
to app llc
you have to write something like this instead of the previous answer otherwise you will get a maximum recursion depth
from urllib import unquote
from django.template.defaultfilters import register
from urllib.parse import unquote #python3
@register.filter
def unquote_new(value):
return unquote(value)
{{ raw|unquote_new }}
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 }}
精彩评论