How to get the current page url in a django template?

I know that there is another question with almost the same name as mine, but the solution in this does not work for me. My url is as follows:

http://domain.com/videos/dvd/1/ 

If I use either {{baseurl}} or {{ request.get_full_path }} , I get only this part:

 http://domain.com/videos/ 

How can I get the whole url? I need to do this from the template level.

EDIT

PS he should ignore any parameters that may be in the url.

+4
source share
1 answer

You can get it in your view and pass it into your template context so that it is available to you.

https://docs.djangoproject.com/en/1.3/ref/request-response/#django.http.HttpRequest.build_absolute_uri

 full_url = request.build_absolute_uri(None) # pass full_url into the template context. 
+8
source

All Articles