Last active
May 13, 2024 02:08
-
-
Save ashishtajane/6531000f8c830717fe62 to your computer and use it in GitHub Desktop.
Get all URL patterns in django
This file contains hidden or 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
# Open django shell and do following. | |
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i have just copy pasted this code to my views but i got circular import error. Here my code
app.views.py
config.urls.py