Use Django's url template tag with special characters
I'm using django's url tag to move from one view to another:
<a href = {% url wiki_view item %}>Read more here</a>
For most "items" this works perfectly. But I have an "item" with a /
character: Sci-Fi/Fantasy. In this instance, I get an error
Caught NoReverseMatch while rendering: Reverse for 'wiki_view' with
arguments '(u'Sci-fi/Fantasy',)' and keyword arguments '{}' not found.
My urls.py is defined as such:
url(r'^wiki/page/(?P<page_title>[^/]*)/$', views.wiki_view, name =
'wiki_view'),
Is there a way for this to work with a "/" character in place like
this? I was advised to use urlencode.
<a href = {% url wiki_view item|urlencode %}>Read more here</a>
This gives the same error. I believe the dev version allows me to use
this:
<a href = {% url wiki_view item|urlencode:"" %}>Read more here</a>
as discussed here: http://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs#urlencode
but I'm on 1.3.0 alpha and I may want to go into production with some
of this code.
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home