Reputation: 121
suppose I have this url
url(r'^delete_group/(\w+)/', 'delete_group_view',name='delete_group')
In template
{%url 'delete_group' 'mwas'%}
works but when I use
{%url 'delete_group' 'mwas 45'%}
is not working. Any way to modify the url to accept both mwas and mwas 45
Upvotes: 0
Views: 54
Reputation: 696
The issue might be your regex. The URL example you're showing has a space in it. \w
won't match spaces. Try this instead: r'^delete_group/([\w\s]+)/
which allows either words or spaces in multiples.
However, know that spaces are not valid in URLs and will likely get converted to %20
or something similar. A best practice is to use hyphens where you would put a space.
I'd also point you at this answer to a similar question.
Upvotes: 1