views:

172

answers:

1

In Django, I'm trying to write a URLconf and view that can take a theoretically unlimited number of "tags". The reason for this is to retrieve objects that have been tagged with different combinations of tags.

For example, URLs like this are desireable:

/topics/tag1/tag2/tag3

The above URL would retrieve "topics" that have been tagged with all 3 tags.

Instead of hard-coding the URLconf like so:

(r'^(?P<tag1>.+)/(?P<tag2>.+)/(?P<tag3>.+)/?$', topic)

I'm looking for a solution that would accept multiple combinations, like so:

/topics/tag3/tag5
/topics/tag5/tag6/tag7/tag9
/topics/tag2

Edit: On the view side, I'd be doing something like:

def topic(request, **kwargs):
    resp = ''
    for arg in kwargs:
        resp += arg + '=' + kwargs[arg] + '<br>'
    return HttpResponse(resp)

Closing: see answer here: http://stackoverflow.com/questions/1072069/recursive-url-patterns-cms-style

+1  A: 

Closing: see answer here: http://stackoverflow.com/questions/1072069/recursive-url-patterns-cms-style

Nick Sergeant