Sometimes, we want to get the current URL within a Python Django template.
In this article, we’ll look at how to get the current URL within a Python Django template.
How to get the current URL within a Python Django template?
To get the current URL within a Python Django template, we can use request.path
or request.get_full_path
.
For instance, we write
{{ request.path }}
{{ request.get_full_path }}
in our template to render the URL without query parameters with request.path
.
And we render the full URL with the query parameters with get_full_path
.
Conclusion
To get the current URL within a Python Django template, we can use request.path
or request.get_full_path
.