Created
December 28, 2011 22:43
-
-
Save dnozay/1530205 to your computer and use it in GitHub Desktop.
discover url patterns in django project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# discover all url patterns in django project | |
# | |
def discover_urls(urllist, parent): | |
for entry in urllist: | |
item = parent.setdefault(entry.regex.pattern, {}) | |
if hasattr(entry, 'url_patterns'): | |
discover_urls(entry.url_patterns, item) | |
# e.g. | |
# | |
# import pprint | |
# registry = {} | |
# from myproj import urls | |
# discover_urls(urls.urlpatterns, registry) | |
# pprint.pprint(registry) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment