开发者

Problem with multi tags

If i have url "/tagged/something/" then it is good, but if i have "/tagged/something1-something2/" it tells me that that page is not found and url didn't matching anything.

urls.py

url(r'^tagged/(?P<tags>\w+)/$', 'show_tagged'),

views.py

def show_tagged(request, tags):
    tags = tags.repla开发者_开发知识库ce(',', '').split('-') 
    items = TaggedItem.objects.get_intersection_by_model(Item, tags)
    return render_to_response('tagged.html', {'items': items}, context_instance=RequestContext(request))

How can i fix this?


Can you try changing your regex? I think the following one will work:

url(r'^tagged/(?P<tags>[\w-]+)/$', 'show_tagged'),
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜