Having trouble writing a url pattern in django
I want to match the following url pattern /posts/tagged/tag-name/
I've tried a few different patterns but Django splits out a 404 because it the url doesn't match any patterns.
This is the pattern I pulled from the docs http://www.webmonkey.com/2010/02/use_url_patterns_and_views_in_django/
(r'^posts/tagged/(?P[-w]+)/$', 'blog.vie开发者_开发百科w.posts_by_tag')
Can anyone one help me out?
Try this:
(r'^posts/tagged/(?P<tag>[-\w]+)/$', 'blog.view.posts_by_tag')
Your posts_by_tag
view will then receive a keyword argument called tag
.
精彩评论