1👍
The following will actually work…
{{ request.GET.param1 }}
… as long as you have the default django.template.context_processors.request
enabled in your settings file.
DJANGO_CONTEXT_PROCESSORS = (
# ...any other context processors you want to run
'django.core.context_processors.request',
)
All this it does is place the request object in your template context, which you can then use to access url parameters. It’s exactly the functionality you’re looking for. See here.
Your only other option is to pass the parameter to the template explicitly, as you describe in your question.
👤tino
- [Answer]-How to query all the elements with this condition in the query?
- [Answer]-Modify UpdateView Form Data Before Presenting To User
- [Answer]-Returning filter on the same template
- [Answer]-Setting up a subscription with Stripe – Django-stripe-payments – Error TemplateDoesNotExist
- [Answer]-RequireJS call to "module"
Source:stackexchange.com