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

Fix an issue with flagged_path and includes #101

Merged
merged 1 commit into from
May 19, 2022
Merged

Conversation

willbarton
Copy link
Member

This change fixes an issue with flagged_path where includes() would not be correctly included, and cannot be resolved using their names.

The issue was simply with our passing of is_endpoint to the pattern class. In the case of path() URLs, the pattern class is RoutePattern, and it doesn’t double-check is_endpoint the way RegexPattern does. I have some more details in #100.

This is a simple fix to change that incorrect True to False.

This closes #100.

This change fixes an issue with `flagged_path` where `includes()` would not be correctly included, and cannot be resolved using their names.

The issue was simply with our passing of `is_endpoint` to the pattern class. In the case of `path()` URLs, the pattern class is `RoutePattern`, and it doesn’t double-check `is_endpoint` the way `RegexPattern` does. I have some more details in #100.

This is a simple fix to change that incorrect `True` to `False`.
@willbarton willbarton requested a review from a team May 17, 2022 19:10
@@ -127,7 +128,7 @@ def _flagged_path(
elif isinstance(view, (list, tuple)):
urlconf_module, app_name, namespace = view

route_pattern = Pattern(route, name=name, is_endpoint=True)
route_pattern = Pattern(route, name=name, is_endpoint=False)
Copy link
Member Author

Choose a reason for hiding this comment

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

This function is a mirror of Django's _path function, which sets is_endpoint to False for include patterns (anything that match (list, tuple)). This change aligns this with Django's, and its misalignment is probably a mistake that's been here since this code was written, but probably didn't show up until Django 2.0 when path() became an option.

@willbarton
Copy link
Member Author

@mkeener would you be able to test if this fixes your issue?

@mkeener
Copy link

mkeener commented May 17, 2022

@willbarton I changed this line in my local and it works as expected, thanks!

@willbarton
Copy link
Member Author

Because this is a single line change to bring our code in line with what Django already implements, and because this strikes me as a fairly major bug, I'm going to go ahead and merge this PR.

@willbarton willbarton merged commit d443fbd into main May 19, 2022
@willbarton willbarton deleted the fix/path-includes branch May 19, 2022 13:37
@adamchainz adamchainz mentioned this pull request Apr 14, 2023
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.

Reverse and resolve issues using includes with namespaces in flagged_path()
2 participants