1

I'm experiencing problems in routing urls to views in Django. Specifically, I use URLs with the pattern:

url(r'^(?P<id>[A-Za-z0-9\ ]+)/(?P<subid>[A-Za-z0-9\ ]+)/managetables$', views.compiledata, name='compiledata')

An example url would be My data/current/managetables. I checked that the regex returns the expected captured groups on www.pyregex.com (example)

However, actually visiting the url does not result in the view being called. Most importantly though, it works for a highly similar url:

url(r'^(?P<id>[A-Za-z0-9\ ]+)/(?P<subid>[A-Za-z0-9\ ]+)/managetab$', views.compiledata, name='compiledata')

If I visit My data/current/managetab the view is called as expected. Additionally, appending a "/" in the urlconf works also - but it is not clear to me why, i.e.:

url(r'^(?P<id>[A-Za-z0-9\ ]+)/(?P<subid>[A-Za-z0-9\ ]+)/managetables/$', views.compiledata, name='compiledata')

and visiting My data/current/managetablesresults in a redirect to My data/current/managetables/which calls the view.

I appreciate any hints how to solve this issue.

Chris
  • 8,268
  • 3
  • 33
  • 46
F. Mueller
  • 11
  • 1
  • 1
    Do you have the full noreversematch stack trace? (Also, spaces don't really work well in urls, you should slugify them) – Sayse Feb 16 '17 at 10:20
  • Thanks for the comment - I will post back as soon as I have additional information. – F. Mueller Feb 16 '17 at 10:28
  • I currently fail to replicate the issue on the machine I'm on - same code though. I will check if the problem persists on the original machine. – F. Mueller Feb 16 '17 at 10:55

1 Answers1

0

Ok, whereas the problem did manifest only on one of two machines, the hint to slugify the urls solved the issue. For anybody encountering similar issues, more information on slugify can be found here: Tango with Django's Chapter 7, as well as in the Django Documentation.

F. Mueller
  • 11
  • 1