The Django url dispatcher is based on regular expressions, so you can provide it with a regular expression that will match the desired path (with duplicate groups). However, I could not find a way to force django url dispatcher to correspond to several subgroups (it returns only the last match as a parameter), so part of the processing of the parameters remains for presentation.
Here is an example url template:
urlpatterns = patterns('', #... (r'^(?P<foldersPath>(?:\w+/)+)(?P<action>\w+)', 'views.folder'), )
In the first parameter, we have a group that does not capture the entry for repeating "word" characters, followed by "/". You might want to change \ w to another to include characters other than alphabet and numbers.
you can, of course, change it to several types in the URL configuration instead of using the action parameter (which is more important if you have a limited set of actions):
urlpatterns = patterns('', #... (r'^(?P<foldersPath>(?:\w+/)+)view', 'views.folder_View'), (r'^(?P<foldersPath>(?:\w+/)+)delete', 'views.folder_delete'), )
and in the views, we break the first parameter to get an array of folders:
def folder(request, foldersPath, action): folders = foldersPath.split("/")[:-1] print "folders:", folders, "action:", action