On Mon, Mar 15, 2010 at 11:28 PM, saxon75 <saxo...@gmail.com> wrote:
> I'm trying to generate a link where the URL of the current page gets
> passed in the querystring of the link.  Like so: <a href="http://
> www.example.com?variable=http%3A%2F%2Fwww.example2.com%2Farg1%2Farg2%2F"></a>.
>
> I would have thought that I could do this relatively easily with
> template tags, so I've tried this:
>
> <% url arg1, arg2 as the_url %>
> <a href="http://www.example.com?variable={{ the_url|urlencode }}"></a>
>
> However, for whatever reason, the urlencode filter isn't applied when
> the_url renders.  Is there a way to do this directly in the template,
> or do I have to generate the encoded URL in the view and pass it to
> the template?

Are you sure it's no applied? urlencode uses python's urllib.quote
(http://docs.python.org/library/urllib.html#urllib.quote)
and I think it doesn't encode the '/' character by default - maybe
that's why you don't see any changes by applying the filter.

Nuno

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to