Django Template Current Page URL
Within a Django template, you can use HttpRequest.build_absolute_uri
to generate the current page URI with the following code:
{{ request.build_absolute_uri }}
If you are using this URL for a social media link, such as Facebook, Twitter, or Google+, you can also add the urlencode
function to encode the uri you are generating.
{{ request.build_absolute_uri|urlencode }}