检查模板中的request.GET变量 [英] Check for request.GET variable in the template

查看:63
本文介绍了检查模板中的request.GET变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

仅在设置了某个GET变量的情况下,我才想在模板中显示某项...。​​我想使用 {%if request.get.my_var%} 会起作用,但不会给我结果。

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.

推荐答案

变量区分大小写-因此,假设lazerscience指出您实际上在上下文中有请求对象,则需要使用 {%if request.GET.my_var%}

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 %}.

这篇关于检查模板中的request.GET变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆