Created
September 14, 2023 00:17
-
-
Save funkybob/49a9f40aad801f80b861e61baa8bc878 to your computer and use it in GitHub Desktop.
Code to dump list of default URL patterns for a Django app (run from manage.py shell)
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
from django.urls import get_resolver | |
res = get_resolver() | |
def get_patterns(m, prefix): | |
nprefix = prefix + (m.pattern.describe(),) | |
yield nprefix | |
for p in getattr(m, 'url_patterns', []): | |
yield from get_patterns(p, nprefix) | |
for p in get_patterns(res, ()): | |
print(' '.join(p)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment