1👍
✅
Your regular expressionfor site_level is [\S]+ which says to match any number of non-whitespace characters. This is called a “greedy match”, meaning that it will match slashes and everything to the end of the URL. So it makes sense that it’s matching all the way to the end of the location.
You should change your regex either to be not greedy, or to only match non-slash characters. That way if a slash occurs, it will be broken into a subsequent part of the location.
url(r'^site/(?P<site_level>[^\/]+)/', site_details, name='site_details'),
Notice I also took out the $ matching the end of the line. You may want to add a second pattern to match the rest after your site_level.
0👍
Perhaps you should change your regular expression to avoid ‘/’ character:
url(r'^site/(?P<site_level>\w+)/(?P<garbage>)\S*)$',
site_details, name='site_details'),
Source:stackexchange.com