Welcome, guest | Sign In | My Account | Store | Cart

This small script shows a simple formatted tree of all defined django url patterns.

Python, 9 lines
1
2
3
4
5
6
7
8
9
import urls

def show_urls(urllist, depth=0):
    for entry in urllist:
        print "  " * depth, entry.regex.pattern
        if hasattr(entry, 'url_patterns'):
            show_urls(entry.url_patterns, depth + 1)

show_urls(urls.urlpatterns)

1 comment

Michael Grünewald (author) 14 years, 1 month ago  # | flag

The related question (Is there a way to get the complete django url configuration?) is here:

http://stackoverflow.com/questions/1828187/determine-complete-django-url-configuration

Created by Michael Grünewald on Wed, 2 Dec 2009 (MIT)
Python recipes (4591)
Michael Grünewald's recipes (7)

Required Modules

Other Information and Tasks