Opened 9 years ago

Closed 4 months ago

#28800 closed New feature (fixed)

Add a management command to list URL patterns

Reported by: Martín Peveri Owned by: Chris Rose
Component: Core (Management commands) Version: 5.1
Severity: Normal Keywords:
Cc: Keryn Knight, Adam Johnson, Ryan Hiebert, Chris Rose, Johanan Oppong Amoateng Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

It would be practical to visualize all the urls of the application in a command, is it possible?. If it is not possible, it is something like this:

python manage.py routes

Change History (39)

comment:1 by Tim Graham, 9 years ago

​django-extensions has a show_urls command which "produce a tab-separated list of (url_pattern, view_function, name) tuples for a project." I'm not sure that this needs to be incorporated into Django itself.

in reply to:  1 comment:2 by Martín Peveri, 9 years ago

I understand, but I depend on an extension. Tell me if you consider it to integrate it into the framework and I could send an RP. Thanks!

comment:3 by Keryn Knight, 9 years ago

Cc: Keryn Knight added

Can I suggest that its worth taking to the developers mailing list to discuss this possibility? As an anecdotal datapoint, I know I semi-frequently make use such a command when coming into a project which I've not previously been heavily involved with. The flat output (vs traversing a list of include() usages) gives a decent overview on what's what, and the contrib.admindocs package already provides a similar overview if installed into the admin.

It also isn't a huge amount of new work (in my mind, because ​I wrote a similar thing to the django-extensions command) precisely because it can depend on the same functions admindocs does. So the maintenance burden is arguably mostly already in place.

comment:4 by Martín Peveri, 9 years ago

I think what Keryn Knight said is good. If approved, I could work on the ticket and send a PR.

Last edited 9 years ago by Martín Peveri (previous) (diff)

comment:5 by Tim Graham, 9 years ago

Component: Core (URLs) → Core (Management commands)
Summary: List routes in the console → Add a management command to list URL patterns
Triage Stage: Unreviewed → Someday/Maybe

Someone could try to get a consensus on the DevelopersMailingList about this. I've never had a need for it myself. A rough criteria I've used for thinking about whether or not something should be in core is whether 80% of projects use it. The existence of an implementation in django-extensions demonstrates this can live as a third-party library which seems sufficient to me.

comment:6 by Xavier Tilley, 4 years ago

Owner: changed from nobody to Xavier Tilley
Status: new → assigned

comment:7 by Carlton Gibson, 4 years ago

Triage Stage: Someday/Maybe → Accepted

Discussion at DjangoCon US 2022 suggests it would be a popular enough feature.

comment:8 by Adam Johnson, 3 years ago

Cc: Adam Johnson added

comment:9 by Natalia Bidart, 3 years ago

​Link to post in the forum where consensus seems quite clear.

Last edited 3 years ago by Natalia Bidart (previous) (diff)

comment:10 by Xavier Tilley, 3 years ago

I have the feature finished I just haven't had time to finished up the tests and documentation. Hopefully my day job will slow down a bit and I can get a PR in next month.

comment:11 by Keanya Phelps, 3 years ago

Owner: changed from Xavier Tilley to Keanya Phelps

in reply to:  8 comment:12 by Alexandr Artemyev, 2 years ago

Replying to Keanya Phelps:
Not sure if this change was made intentionally or by mistake.

Replying to Xavier Tilley:

I have the feature finished I just haven't had time to finished up the tests and documentation. Hopefully my day job will slow down a bit and I can get a PR in next month.

Do you still plan to make these changes?

Replying to Adam Johnson:
Could we push this feature?

comment:13 by Ryan Hiebert, 2 years ago

Cc: Ryan Hiebert added

comment:14 by Chris Rose, 2 years ago

Cc: Chris Rose added
Has patch: set
Needs tests: set
Version: 1.11 → 5.1

I've picked up the work started by Xavier Tilley and pushed a bit more onto it: ​https://github.com/django/django/pull/18347

Last edited 2 years ago by Chris Rose (previous) (diff)

in reply to:  14 comment:15 by Ülgen Sarıkavak, 2 years ago

Owner: changed from Keanya Phelps to Ülgen Sarıkavak

I've pinged Chris under the Github issue and with ​his approval, I'm taking the task. My plan is, first to consider which formatting options are needed, then to push the finalized version this weekend.

Replying to Chris Rose:

I've picked up the work started by Xavier Tilley and pushed a bit more onto it: ​https://github.com/django/django/pull/18347

Last edited 2 years ago by Ülgen Sarıkavak (previous) (diff)

comment:16 by Ülgen Sarıkavak, 2 years ago

Patch needs improvement: set

comment:17 by Ülgen Sarıkavak, 23 months ago

Patch needs improvement: unset

The PR is ready to be reviewed 🙌🏻

comment:18 by Ülgen Sarıkavak, 23 months ago

Needs tests: unset

comment:19 by Ülgen Sarıkavak, 23 months ago

Triage Stage: Accepted → Ready for checkin

comment:20 by Ülgen Sarıkavak, 23 months ago

Triage Stage: Ready for checkin → Accepted

I'm a bit confused about who should set the "Ready for checkin" flag. The current info box on this page says

For a Django committer to do a final review of the patch and merge it if all looks good.

so I thought this is the correct state to be in but now the issue is no longer visible under https://code.djangoproject.com/query?status=!closed&needs_better_patch=0&needs_tests=0&needs_docs=0&has_patch=1&stage=Accepted&desc=1&order=changetime so I guess I shouldn't have touched that flag. Considering

If you’re really not certain if a ticket is ready, don’t mark it as such.

warning from ​https://docs.djangoproject.com/en/dev/internals/contributing/new-contributors/#be-cautious-when-marking-things-ready-for-check-in , I'm changing that flag back.

Sorry for the extra notifications going to the followers of the issue.

comment:21 by Sarah Boyce, 22 months ago

Patch needs improvement: set

comment:22 by Fabio Pozzi, 12 months ago

I was wondering if this is being worked on or if I can try to pick it up.

comment:23 by Adam Johnson, 12 months ago

You can try picking it up, copying the existing PR and addressing the feedback! We call it the vulture strategy: ​https://youtu.be/A-3eTMNQ3rM?si=F3UmjFl_IfXk-3uH

comment:24 by Ülgen Sarıkavak, 12 months ago

We give some time to original author to respond before vulturing tho :)

Let me give push the changes I had in mind first and if that gets a big review that I have no time to handle, I will inform you.

comment:25 by Chris Rose, 12 months ago

I'm not actively working on it at the moment, so as far as I'm concerned go ahead.

in reply to:  24 ; comment:26 by Johanan Oppong Amoateng, 10 months ago

Replying to Ülgen Sarıkavak:

We give some time to original author to respond before vulturing tho :)

Let me give push the changes I had in mind first and if that gets a big review that I have no time to handle, I will inform you.

Are you still actively working on this ticket?

comment:27 by Johanan Oppong Amoateng, 10 months ago

Cc: Johanan Oppong Amoateng added

in reply to:  26 ; comment:28 by Ülgen Sarıkavak, 10 months ago

Replying to Johanan Oppong Amoateng:

Are you still actively working on this ticket?

Sorry for the silence on my end, but yes I am. Because the review process for my initial submission was overwhelming and not really productive in my opinion, I'm trying to pursue a different path, creating the command as a 3rd party library. I can share the link here when it's ready - but I promise it won't take longer than a week.

If you don't get another notification with a repo link in a week, please feel free to move forward with the task.

in reply to:  28 comment:29 by Johanan Oppong Amoateng, 10 months ago

Replying to Ülgen Sarıkavak:

Replying to Johanan Oppong Amoateng:

Are you still actively working on this ticket?

Sorry for the silence on my end, but yes I am. Because the review process for my initial submission was overwhelming and not really productive in my opinion, I'm trying to pursue a different path, creating the command as a 3rd party library. I can share the link here when it's ready - but I promise it won't take longer than a week.

If you don't get another notification with a repo link in a week, please feel free to move forward with the task.

noted thank you

comment:30 by Chris Rose, 4 months ago

I'm currently at PyCon US and was hoping I could either get ​https://github.com/django/django/pull/18769 (by Ülgen) or my own ​https://github.com/django/django/pull/18347 across the line.

I don't know why the two PRs got caught up in a very long back and forth process over what looks like a relatively simple management command, but I'd like to finish this up and land it.

comment:31 by Chris Rose, 4 months ago

Owner: changed from Ülgen Sarıkavak to Chris Rose
Patch needs improvement: unset

comment:32 by Jacob Walls, 4 months ago

Patch needs improvement: set

Looking good, left a question about the DJANGO_COLORS env var.

comment:33 by Chris Rose, 4 months ago

Patch needs improvement: unset

comment:34 by Jacob Walls, 4 months ago

Needs tests: set
Patch needs improvement: set

Need to handle class-based views, which I think were supported in the django-extensions version, included a proposed fix.

comment:35 by Chris Rose, 4 months ago

Patch needs improvement: unset

comment:36 by Jacob Walls, 4 months ago

Needs tests: unset
Triage Stage: Accepted → Ready for checkin

comment:37 by Jacob Walls <jacobtylerwalls@…>, 4 months ago

In 804660d6:

Refs #28800 -- Lifted some url functions from admindocs into urls.utils.

comment:38 by Jacob Walls <jacobtylerwalls@…>, 4 months ago

In 22d25eff:

Refs #28800 -- Handled escaped literals in simplify_regex().

comment:39 by Jacob Walls <jacobtylerwalls@…>, 4 months ago

Resolution: → fixed
Status: assigned → closed

In 9383fae0:

Fixed #28800 -- Added a listurls management command.

Thanks JaeHyuck Sa, Jacob Walls, and Tim McCurrach for reviews.

Co-authored-by: Ülgen Sarıkavak <ulgensrkvk@…>

Note: See TracTickets for help on using tickets.
Back to Top