Skip to content

Fixed #32565 -- Moved internal UrlResolver used only by admindocs to admindocs. - #21137

Open
nonock wants to merge 1 commit into
django:mainfrom
nonock:ezvany/ticket_32565
Open

nonock wants to merge 1 commit into
django:mainfrom
nonock:ezvany/ticket_32565

Conversation

@nonock

@nonock nonock commented Apr 19, 2026 •

Copy link
Copy Markdown

ticket-32565

Branch description

Extracted function UrlResolver._is_callback, UrlResolver.lookup_str and attribute UrlResolver._callback_strs from UrlResolver to be closer to use inside admindocs.

AI Assistance Disclosure (REQUIRED)

  • No AI tools were used in preparing this PR.
  • If AI tools were used, I have disclosed which ones, and fully reviewed and verified their output.

I used Claude Opus 4.7 to create a base of test that I had almost completely rewrite and do a first review of my changes.
I have manually reviewed, edited, and verified all code and documentation.

Checklist

  • This PR follows the contribution guidelines.
  • This PR does not disclose a security vulnerability (see vulnerability reporting).
  • This PR targets the main branch.
  • The commit message is written in past tense, mentions the ticket number, and ends with a period (see guidelines).
  • I have not requested, and will not request, an automated AI review for this PR.
  • 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.

@github-actions

Copy link
Copy Markdown

Thank you for your contribution to Django! This pull request has one or more items that need attention before it can be accepted for review.

⚠️ Warning: Incorrect Trac Ticket Flag

The referenced ticket ticket-32565 does not have the Has patch flag set in Trac. This flag must be checked before a pull request can be reviewed.

What to do:

  1. Open the ticket at https://code.djangoproject.com/ticket/32565.
  2. Scroll down and check the Has patch checkbox on the ticket.
  3. Save the ticket.

For more information see https://docs.djangoproject.com/en/dev/internals/contributing/triaging-tickets/#has-patch.

If you have questions about these requirements, please review the contributing guidelines or ask for help on the Django Forum.

1 similar comment
@github-actions

Copy link
Copy Markdown

Thank you for your contribution to Django! This pull request has one or more items that need attention before it can be accepted for review.

⚠️ Warning: Incorrect Trac Ticket Flag

The referenced ticket ticket-32565 does not have the Has patch flag set in Trac. This flag must be checked before a pull request can be reviewed.

What to do:

  1. Open the ticket at https://code.djangoproject.com/ticket/32565.
  2. Scroll down and check the Has patch checkbox on the ticket.
  3. Save the ticket.

For more information see https://docs.djangoproject.com/en/dev/internals/contributing/triaging-tickets/#has-patch.

If you have questions about these requirements, please review the contributing guidelines or ask for help on the Django Forum.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

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 ⛵️!

…admindocs.

Extracted function `_is_callback`, `lookup_str` and attribute `_callback_strs` from UrlResolver to be closer to use inside admindocs.

@blighj blighj left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the interest in contributing to django. Welcome aboard.

This looks like the right approach to me, compared to the earlier PR that had to be reverted.

The tests that prove it doesn't regress don't look correct though, I think the admindocs before admin test is not needed. We could test the threading regression with something like:

    def test_is_callback_in_thread(self):
        """
        _is_callback() works on threads other than the one that imported
        django.contrib.admindocs.utils (#33955).
        """
        resolver = get_resolver("admin_docs.urls")
        results = []
        thread = threading.Thread(
            target=lambda: results.append(
                _is_callback("admin_docs.views.XViewClass", resolver)
            )
        )
        thread.start()
        thread.join()
        self.assertEqual(results, [True])

What do you think?

Comment thread tests/apps/tests.py
@override_settings(
INSTALLED_APPS=["django.contrib.admindocs", *SOME_INSTALLED_APPS]
)
def test_valid_order_between_admin_docs_and_admin(self):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we need this test? it passes without the change and passes on the old 4.1 branch with the fix that needed reverting, so it is not testing anything useful, the doc string is quoting 33955 twice. The quickest fix is to remove it if we don't need it.

Comment thread docs/releases/6.1.txt
Comment on lines +518 to +521
* The undocumented ``URLResolver._is_callback()``,
``URLResolver._callback_strs``, and ``URLPattern.lookup_str()`` are
moved to ``django.contrib.admindocs.utils``.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is the exact same as the original release note in 4.1, which was never removed and no other note never said it was reverted. It probably needs something to say it had been reverted, or maybe we could remove it now from 4.1.txt?

@jacobtylerwalls jacobtylerwalls self-assigned this Aug 12, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants