Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#29068 closed Bug (needsinfo)

Django urlpatterns has limit of allowed urls with namespace?

Reported by: Gerben Morsink Owned by: nobody
Component: Core (URLs) Version: 1.11
Severity: Normal Keywords: urlpatterns limit
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


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 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 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 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 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'))]

Change History (2)

comment:1 by Tim Graham, 6 years ago

Resolution: needsinfo
Status: newclosed

You should debug your code and confirm that Django is at fault before creating a ticket. We can't triage the issue without a sample project to reproduce it. Please reopen the ticket if you can do one of those things. Thanks.

comment:2 by Gerben Morsink, 6 years ago

I have found the issue.

I had an url of type:

url(r'^aboutus/$', RedirectView.as_view(url=reverse('aboutus'), permanent=True))

in my Where the 'aboutus' url was defined somewhere above in an included sub

With the Django testserver this works fine, but in production (Apache + WSGI) it gives a lot of seemingly strange errors, such as unexpected 404s and (after including the package silk) unexpected 500 errors. The strange thing was, that it did work on the test server (also Apache + WSGI), but not on the live server. It gave me some pulled out grey hair, so I hope someone finds this anwers when the need is there.

Version 3, edited 6 years ago by Gerben Morsink (previous) (next) (diff)
Note: See TracTickets for help on using tickets.
Back to Top