Django urlencode multiple variables in a template

I want url to encode the following internal pattern

{{address.street}} {{address.city}} {address.state}}

do it anyway from the side of the template and put it in href (I prefer NOT to combine them on the server side):

<a href="http://maps.google.com/maps?daddr=<!-- OVER HERE --!>">Map It</a> 

thanks!

+4
source share
1 answer
 <a href="http://maps.google.com/maps?daddr={{address.street|urlencode}} {{address.city|urlencode}} {{address.state|urlencode}}"> 

I'm not sure how you wanted to combine them, I just used a space. Or:

 <a href="http://maps.google.com/maps?daddr={% filter urlencode %}{{address.street}} {{address.city}} {{address.state}}{% endfilter %}"> 
+4
source

All Articles