Django urlpatterns has limit of allowed urls with namespace?
|Patch needs improvement:
I'm currently working on a huge site with a huge number of distinct urlpatterns, that are categorized in a tree pattern, starting with the project's urls.py and then going down the tree with include statements (sometimes namespaced), which in turn have their own include statements, untill we are about 4 branches away.
Next to that many urlpatterns are conditional (if settings.DEBUG ... if 'app_x' in installed_apps... etc).
I have had issues with one of the last urlpatterns in the project's urls.py a lot on my production environment, on apache + wsgi ('No reverse found'), which I couldn't reproduce on my development machine with runserver . It has a namespace set. It was not a user facing endpoint so I forgot about it.
Now I have added another urlpattern to the project's urls.py with a namespace and it too gives 'No reverse found' (it is reversed in a middleware, so the app does not start at all, making it easier to test).
When I place the last urlpattern up in the projects urls.py that it comes as the second urlpattern, the app does start, so it looks like the urlpatterns are going into some kind of limit.
For your reference this is the code that works when placed after the first urlpatterns definition, but not when placed at the bottom (I think nothing special).
if 'silk' in settings.INSTALLED_APPS: urlpatterns += [url(r'^silk/', include('silk.urls', namespace='silk'))]