Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#21530 closed Bug (fixed) AttributeError: 'RegexURLPattern' object has no attribute 'app_name'

Reported by: Damian.Myerscough@… Owned by: nobody
Component: Core (URLs) Version: 1.6
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description (last modified by bmispelon)

The file does not support the ability of supplying one URL. When specifying one URL within the file you get the following error:

(nagios-api-env)dmyerscough-ltm:nagios_restful dmyerscough$ python runserver
Validating models...

0 errors found
November 29, 2013 - 09:53:03
Django version 1.6, using settings 'nagios_restful.settings'
Starting development server at
Quit the server with CONTROL-C.
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/", line 85, in run
    self.result = application(self.environ, self.start_response)
  File "/Users/dmyerscough/nagios-api-env/lib/python2.7/site-packages/django/contrib/staticfiles/", line 67, in __call__
    return self.application(environ, start_response)
  File "/Users/dmyerscough/nagios-api-env/lib/python2.7/site-packages/django/core/handlers/", line 206, in __call__
    response = self.get_response(request)
  File "/Users/dmyerscough/nagios-api-env/lib/python2.7/site-packages/django/core/handlers/", line 148, in get_response
    response = debug.technical_404_response(request, e)
  File "/Users/dmyerscough/nagios-api-env/lib/python2.7/site-packages/django/views/", line 471, in technical_404_response
    and tried[0][0].app_name == tried[0][0].namespace == 'admin')):
AttributeError: 'RegexURLPattern' object has no attribute 'app_name'
[29/Nov/2013 09:53:06] "GET / HTTP/1.1" 500 59

To reproduce this error you can do the following:

  1. Edit the file and add the following:
    from django.conf.urls import patterns, include, url
    urlpatterns = patterns('',
        url(r'^test/', 'nagios_api.views.comments', name='home'),
  1. Run your project and navigate to the web page and you get the above exception.

I have created a Pull request on GitHub to fix the issue -

Change History (6)

comment:1 Changed 2 years ago by bmispelon

  • Description modified (diff)
  • Needs documentation unset
  • Needs tests set
  • Patch needs improvement set
  • Severity changed from Normal to Release blocker
  • Triage Stage changed from Unreviewed to Accepted


I can indeed reproduce this issue when the root urlconf only contains one non-empty pattern.
The urlconf itself works (I can access my view by navigating to the correct URL) but the problem is in the debug view.

If I try to access a URL that's not mapped to anything, the debug view is triggered and the reported exception occurs.

Note that this only affects the 1.6 and master branch, and that this regression was introduced by commit 3f1c7b70537330435e2ec2fca9550f7b7fa4372e.

As for your patch, it does seem to fix the issue and it even passes the full test suite but it seems wrong to just be removing code.
In any case, a full patch will also require a regression testcase so I'm marking this as patch needs improvement.


comment:2 Changed 2 years ago by anonymous

I updated the pull request ( as a better solution was provided by Aymeric Augustin

comment:3 Changed 2 years ago by aaugustin

  • Severity changed from Release blocker to Normal

Now this just needs tests.

I don't think a crash of the debug view is a relatively rare case is a release blocker. Baptiste, feel free to set back the flag if you disagree.

comment:4 Changed 2 years ago by alasdair

  • Needs tests unset

I had a go at writing tests. Pull request

comment:5 Changed 2 years ago by Baptiste Mispelon <bmispelon@…>

  • Resolution set to fixed
  • Status changed from new to closed

In a020dd0a99da13d0f024d42c46f01d8f503e9d5e:

Fixed #21530 -- Prevent AttributeError in default URLconf detection code.

Thanks to @dmyerscoug for the report and original patch
and to @alasdairnicol for the added tests.

comment:6 Changed 2 years ago by Baptiste Mispelon <bmispelon@…>

In 5a4884a978d48a21e765141cd9a4c37448875a85:

[1.6.x] Fixed #21530 -- Prevent AttributeError in default URLconf detection code.

Thanks to @dmyerscoug for the report and original patch
and to @alasdairnicol for the added tests.

Backport of a020dd0a99da13d0f024d42c46f01d8f503e9d5e from master.

Note: See TracTickets for help on using tickets.
Back to Top