I want to display a certain in the template only if a certain GET variable is set....I thought using {% if request.get.my_var %}
would work, but it's not giving me the results.
In the template, you use the hash symbol, # , to declare a template variable. The following template variable, #phone , declares a phone variable with the <input> element as its value. Refer to a template variable anywhere in the component's template.
get notation is to specify a default value of no value is present. E.g.: request. META. get("HTTP_REFERER", "localhost") would cause it to either return the actual value of HTTP_REFERER or return localhost if there is no HTTP_REFERER.
Variables are case-sensitive - so, assuming as lazerscience points out that you actually have the request object in the context, you would need to use {% if request.GET.my_var %}
.
Check if you have django.core.context_processors.request
in your TEMPLATE_CONTEXT_PROCESSORS
in settings.py
.
If not put it there, or add request yourself to your rendered context.
http://docs.djangoproject.com/en/dev/ref/templates/api/#django-core-context-processors-request
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With