The django-extensions library has a fantastic management command called
show_urls which will print all of the urls in your project. This is an extremely helpful debugging tool when dealing with URL routing issues. At the same time, it seems like it’s a somewhat unknown tool.
There was a discussion on the Fediverse about the package and I wanted to bring it up to the broader community.
- Did you know about this command?
- Do you use it regularly?
- Do you feel like Django’s standard library should contain a similar command?
I’d like this to be included. I don’t always have Django-extensions installed, but I often deliberately hit the 404 page in order to get the list of URLs patterns displayed. Being able to just do that at the CLI would save a bit of silliness there. (So a +1 from me.)
There’s an old ticket for it.
This was Someday/Maybe for a long time, but I moved it to Accepted during DjangoCon US 2022, because there was a discussion about it expressing all/multiple positives.
Oh wow, I use django-extensions in almost every dev project, but was not aware of that command
+1 for having something similar in standard batteries.
While I can’t say that I use it weekly or monthly, when I need it, I go out of my way to install
django-extensions if it’s not already installed in a project to use it.
Otherwise, I have to go deep into a project’s code to try and figure out what some third-party package may or may not have named their URL path. Even then, you must still know the names space if it’s passed to the path or a router name.
So, show_urls solves an unobvious problem that I’m unsure how else to figure out.
Django-extensions is part of our standard installation process as much as psycopg2-binary, celery, and django-crispy-forms.
I’m guessing at this point that I had forgotten that show_urls wasn’t a core command…
- I did not know!
- I wish
- Yes, absolutely.
Currently I do the exact same thing that Carlton described, particularly I always use http://localhost:8000/foo/ to get there. The day that a 3rd party app decides to provide a valid view under
foo I’m doomed!
show_urls regularly and find debugging URL matches one of the more frustrating parts of Django development. In several projects I’ve either installed
django_extensions temporarily or copied the code to a live console at some point.
Strong +1 to include functionality like this in Django-proper – it doesn’t seem too complex, depending on if we want all the different output options etc.
1. Did you know about this command?
2. Do you use it regularly?
Yes, more than any other management command. Especially after
black took over the world, it’s become hard to quickly “scan” the URL structure by just looking at the code, so having it in table form is very useful.
3. Do you feel like Django’s standard library should contain a similar command?
Yes, although it could probably be acceptable to only output CSV, for further processing by other commands like
I linked this post in the corresponding ticket-28800. Can’t wait to have this feature!