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 cannot call a function that requires arguments in a template. Write a template tag or filter instead.
{% %} and {{ }} are part of Django templating language. They are used to pass the variables from views to template. {% %} is basically used when you have an expression and are called tags while {{ }} is used to simply access the variable.
extends tag is used for inheritance of templates in django. One needs to repeat the same code again and again. Using extends we can inherit templates as well as variables.
A for loop is used for iterating over a sequence, like looping over items in an array, a list, or a dictionary.
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 }}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With