Is there a way to get the current page URL and all its parameters in a Django template?
For example, a templatetag that would print a full URL like /foo/bar?param=1&baz=2
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Write a custom context processor. e.g.
add a path to that function in your
TEMPLATE_CONTEXT_PROCESSORSsettings variable, and use it in your template like so:If you want to have the full
requestobject in every request, you can use the built-indjango.core.context_processors.requestcontext processor, and then use{{ request.get_full_path }}in your template.See: