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

Expose URL resolver match for RoutablePageMixin #11953

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

Conversation

chosak
Copy link
Member

@chosak chosak commented May 14, 2024

Django provides an HttpRequest.resolver_match attribute that allows downstream code to inspect a request object to see how its URL was resolved to a view.

Wagtail's RoutablePageMixin does its own sub-URL routing to call different view functions on a page object, but the resolver result isn't similarly made available.

This commit sets a new routable_resolver_match attribute on the request object, akin to Django's resolver_match, that stores this sub-URL routing information for downstream use.

Documentation has been updated appropriately (along with a couple of other minor broken things in the RoutablePageMixin docs):

image

Django provides an `HttpRequest.resolver_match` attribute [0] that
allows downstream code to inspect a request object to see how its URL
was resolved to a view.

Wagtail's RoutablePageMixin does its own sub-URL routing to call
different view functions on a page object, but the resolver result isn't
similarly made available.

This commit sets a new `routable_resolver_match` attribute on the
request object, akin to Django's `resolver_match`, that stores this
sub-URL routing information for downstream use.

Documentation has been updated appropriately (along with a couple of
other minor broken things in the RoutablePageMixin docs).

[0] https://docs.djangoproject.com/en/5.0/ref/request-response/#django.http.HttpRequest.resolver_match
@chosak chosak added the component:RoutablePageMixin Routable page mixin (contrib) label May 14, 2024
Copy link

squash-labs bot commented May 14, 2024

Manage this branch in Squash

Test this branch here: https://chosakfeatureroutable-resolver-vys1s.squash.io

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:RoutablePageMixin Routable page mixin (contrib)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant