How to get URL of current page, including parameters, in a template?

Write a custom context processor. e.g.

def get_current_path(request):
    return {
       'current_path': request.get_full_path()
     }

add a path to that function in your TEMPLATE_CONTEXT_PROCESSORS settings variable, and use it in your template like so:

{{ current_path }}

If you want to have the full request object in every request, you can use the built-in django.core.context_processors.request context processor, and then use {{ request.get_full_path }} in your template.

See:

Leave a Comment