[Answer]-Django urlpattern for repeating group?

1đź‘Ť

âś…

With regex patterns, the number of groups is “fixed at compile time”. You’ll need to make a group that matches n-repetitions of your pattern and then split it after you’ve captured it.

You’ll need to use something like ^(?P<categories>(?:[\w]+\/?)+)$

Then in your view,

categories = filter(bool, categories.split('/'))
👤DanielB

Leave a comment