开发者

Problem with multi tags

开发者 https://www.devze.com 2023-04-01 11:00 出处:网络
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.

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

精彩评论

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