How to get the current URL of a page in a Django template?
I know there is another question with virtually the same title as mine but the solution in that one didn't work for me. My url is like this:
http://开发者_如何学Pythondomain.com/videos/dvd/1/
If I use either {{baseurl}}
or {{ request.get_full_path }}
I get just this part:
http://domain.com/videos/
How can I get the entire url? I need to be able to do this from the template level.
EDIT
P.S. it should disregard any parameters that may be in the url.
You could get it in your view and pass it along into your template context so that it is available to you there.
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.
精彩评论