Should the show_urls command be part of Django's standard library?

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.

  1. Did you know about this command?
  2. Do you use it regularly?
  3. Do you feel like Django’s standard library should contain a similar command?
4 Likes

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.

https://code.djangoproject.com/ticket/28800

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.

4 Likes

Oh wow, I use django-extensions in almost every dev project, but was not aware of that command :open_mouth:

+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…

2 Likes
  1. I did not know!
  2. I wish :slight_smile:
  3. 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!

3 Likes

I use 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 Like
  1. Yes
  2. Yes
  3. Yes
  1. Yes
  2. Irregularly
  3. Yes. Let’s not have half a dozen output formats though.
1 Like
  1. Yes.
  2. Yes. I use it to jump directly to views on large codebases.
  3. Yes. I always forget that it isn’t core.

1. Did you know about this command?
Yes

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 xsv.

I linked this post in the corresponding ticket-28800. Can’t wait to have this feature! :wink:

3 Likes