I don't know if it's the right solution but I made a custom filter.

import urllib

@register.filter
def custom_urlencode(url):
    return urllib.urlencode({'category': url})

Seems to work just fine. Spaces are now replaced by a '+'.


On May 29, 10:08 pm, Michael <folderpla...@gmail.com> wrote:
> Hi and thanks for your reply. The problem is that I will autoload
> excel files into the database without a slug field. So I guess I need
> to filter the categories by the exact same name and that's why I
> started with the parameters.
>
> On 29 mei, 18:19, "scot.hac...@gmail.com" <scot.hac...@gmail.com>
> wrote:
>
> > On May 28, 1:04 pm, Michael <folderpla...@gmail.com> wrote:
>
> > > If I look to the admin is see that for example spaces are replaced by
> > > a '+' sign and & is replaced by '%26'. I have just white spaces and
> > > the & sign in my parameters. To avoid this I have put the urlencode
> > > filter in my template.
>
> > > Example:
>
> > > {% for category in category_list %}
> > > <a href="?category={{ category.name|urlencode }}">{{ category.name }}</
> > > a><br/>
> > > {% endfor %}
>
> > Maybe not the answer you're looking for, but seems like a better job
> > for category.slug, so you don't have to worry about parsing for
> > whitespace, etc. That's what slugs are for!
>
> > ./s
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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