Getting 'path' of previous URL from template

Viewed 1741

I know I can get the previous URL in the template by using the following:

{{ request.META.HTTP_REFERER}}

But I want to know if I there's a way to get only the path and not the absolute URL (i.e /my-page instead of http://localhost:8000/my-page)

Like in the view we can do:

from urllib import parse
parse.urlparse(request.META.get('HTTP_REFERER')).path

Can I do something like that in the template as well?

Update (with more info): My usecase is to compare the previous url with another url within the same site to see if the user came in from there

2 Answers
Related