[Fixed]-Django: How to know the the name of the URL that is attending a certain request

1👍

You can use the resolve function to find out how Django is resolving your URL:

from django.urls import resolve
result = resolve('my_url')

This returns a ResolverMatch object which has attribute for the url_name that matched your URL and the func which it will be routed to.

Leave a comment