I have a certain link to a url in a Django template. I would like to grab all the GET parameters of the current page url and add them to the url of the template’s link. The current page might have zero GET parameters.
Share
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.
Include the
django.core.context_processors.requestcontext processor in yoursettings.py, then use therequestobject in your template’s links:This will cause links from a page without any GET variables to have a trailing
?but that’s harmless. If that’s not acceptable, you could test for them first: