Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a listurls management command #18347

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

offbyone
Copy link

@offbyone offbyone commented Jul 7, 2024

Trac ticket number

ticket-28800

Branch description

This picks up work started by @hippietilley on their hippietilley/django#ticket_28800 branch.

I have made a couple of changes:

  • added documentation for the command
  • support for multiple URL prefixes
  • support for a table output

Checklist

  • This PR targets the main branch.
  • The commit message is written in past tense, mentions the ticket number, and ends with a period.
  • I have checked the "Has patch" ticket flag in the Trac system.
  • I have added or updated relevant tests.
  • I have added or updated relevant docs, including release notes if applicable.
  • I have attached screenshots in both light and dark modes for any UI changes.

Notes

I was unable to find where tests for management commands belong; happy to add them, but wasn't aware of how.

I'm not sure what documentation other than the manual should be updated; I'd love it if someone pointed me at that.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello! Thank you for your contribution 💪

As it's your first contribution be sure to check out the patch review checklist.

If you're fixing a ticket from Trac make sure to set the "Has patch" flag and include a link to this PR in the ticket!

If you have any design or process questions then you can ask in the Django forum.

Welcome aboard ⛵️!

@adamchainz
Copy link
Sponsor Member

I will try to do a full review during the week. But for now, I would note that you need to squash your commits into one and follow the commit style guide, and update the PR title to match.

@offbyone offbyone force-pushed the ticket_28800 branch 2 times, most recently from a3a6ab6 to 845340d Compare July 7, 2024 23:44
@offbyone offbyone changed the title Ticket 28800 Add a listurls management command Jul 7, 2024
Introduce a new admin command that lists URLs in the application, either
in a long form or in a compact tabular form. It includes an option to
limit the listing to URL prefixes.
@offbyone
Copy link
Author

offbyone commented Jul 8, 2024

Hopefully this meets approval. I went back and forth on the commit message a few times, apologies for the chaos.

Copy link
Member

@smithdc1 smithdc1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pushing this forward! 🥇

I've left a few small comments inline. One thing I noticed when testing is that the output with the --table option seems a bit surprising.

In my test project with django-extensions I see.

/       bootstrap4.views.index
/bootstrap3     bootstrap3.views.index  bootstrap3.views.index

With the new listurls command:

        <function index at 0x000002216F5DF600>.index
django  <function index at 0x000002216F634E00>.index    django_rendering.views.index

I can see two differences. The urls do not have a leading / which I'm not sure is an issue but means that nothing is shown for the / case. Also the view_methods are incorrectly formatted.

The leading / is also an issue for the longer output format where the URL field is blank.

URL:
View: bootstrap4.views.index
Arguments:

docs/releases/5.1.txt Show resolved Hide resolved
docs/ref/django-admin.txt Show resolved Hide resolved
help="Only list URLs with these URL prefixes.",
)

parser.add_argument(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to have multiple output formats? I couldn't see any discussion on this, so apologies if I've missed something here.

The table option seems closer to what django-extensions show_urls does?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The table option is what show_urls did, but the long form is what @hippietilley put in their original patch; given I was carrying on their work, it seemed polite to include their format. I'm happy to reverse the defaults, or elide it, but I didn't want to be rude about the work they already did.

@offbyone
Copy link
Author

offbyone commented Jul 8, 2024

I'll look at the output again; I suspect I missed something in the view lookup code and URL formatting. Updates to come.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants