Opened 5 years ago

Closed 5 years ago

#16573 closed Bug (fixed)

admindocs "views" view returns no urls

Reported by: lopopolo Owned by: nobody
Component: contrib.admindocs Version: master
Severity: Release blocker Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no


The conditions in the if in extract_views_from_url patterns are in the wrong order. This results in all of my root level urls matching a nil view function. Swapping the if and elif conditions fixes the problem

Diff is attached.

Attachments (1)

extract_views_from_urlpatterns_diff.txt (1.1 KB) - added by lopopolo 5 years ago.
git diff of proposed fix

Download all attachments as: .zip

Change History (7)

Changed 5 years ago by lopopolo

git diff of proposed fix

comment:1 Changed 5 years ago by Aymeric Augustin

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Resolution: needsinfo
Status: newclosed

You lost me at:

This results in all of my root level urls matching a nil view function.

What's a "nil view function"?

More generally, what's the problem and how do I reproduce it? What's the expected result, and the actual result?

comment:2 Changed 5 years ago by lopopolo

Resolution: needsinfo
Status: closedreopened

When visiting /admin/doc/views
Instead of building a list of all of the functions defined in my apps' views and their associated urls,
the function extract_views_from_url_patterns returns a list of tuples of the form
(None, <url from root level>)

For example:
(None, "admin/doc/"),
(None, "admin/"),
(None, "myapp/")

To reproduce, visit

comment:3 Changed 5 years ago by Aymeric Augustin

Resolution: worksforme
Status: reopenedclosed

When I visit that URL on my projects, I get a listing of my URLs and views, as expected.

We need more information to reproduce your problem. For instance, could you build a minimal project that exhibits the issue?

comment:4 Changed 5 years ago by lopopolo

Resolution: worksforme
Status: closedreopened

This django project, which uses a recent version of trunk exhibits the error:

Visiting http://localhost/ssb/doc/views when running the development server should exhibit the problem

comment:5 Changed 5 years ago by Aymeric Augustin

Needs tests: set
Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted

Good catch. This is a regression introduced at r16405.

With a checkout of your project (but that project has nothing special, the result would be the same with any Django site), and r16404 of Django, it works.

With r16405, I get this exception:


Request Method: GET
Request URL: http://localhost:8000/ssb/doc/views/

Django Version: 1.4 pre-alpha SVN-16405
Python Version: 2.6.6
Installed Applications:
Installed Middleware:

File "/Users/myk/Desktop/hyperbola/hyperbola/django/core/handlers/" in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
File "/Users/myk/Desktop/hyperbola/hyperbola/django/contrib/admin/views/" in _checklogin
  16.             return view_func(request, *args, **kwargs)
File "/Users/myk/Desktop/hyperbola/hyperbola/django/contrib/admindocs/" in view_index
  137.                 'module': func.__module__,

Exception Type: AttributeError at /ssb/doc/views/
Exception Value: 'NoneType' object has no attribute '__module__'

comment:6 Changed 5 years ago by Jannis Leidel

Resolution: fixed
Status: reopenedclosed

In [16609]:

Fixed #16573 -- Corrected a regression in the admindocs app's view overview introduced in r16405. Thanks, lopopolo.

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