我试图在django项目模板中过滤我的列
目前我可以在表中搜索并显示具有该值的行
但是我想添加一个dropdown
菜单,它将请求特定的列值,然后根据该值进行筛选
目前我的代码是
在视图.py在
def user_profile(request):
q = request.GET.get('q','')
custom = Customer.objects.all()
if q:
custom1=custom.filter(name__contains=q)
custom2=custom.filter(Product__contains=q)
custom3=custom.filter(L3__contains=q)
custom4=custom.filter(Server_Type__contains=q)
custom5=custom.filter(Version__contains=q)
custom6=custom.filter(Status__contains=q)
custom7=custom.filter(PM__contains=q)
custom8=custom.filter(CDM__contains=q)
custom = custom1 | custom2 | custom3 | custom4 | custom5 | custom6 |
custom7 | custom8
这里的name product l3是我要从中筛选的模型中的字段
在我的主页.html在
^{pr2}$我的js.js公司在
function go(){
// alert("hellonikhar");
var q = document.getElementById("search").value;
window.open("/?q="+q,"_self");
}
我把在文本框中输入的值存储在var q中并显示数据,但是我想先添加一个下拉列表来选择字段,然后q应该只基于该列进行过滤
添加一个以id作为列名的下拉列表,并使用该列值过滤对象。在
要添加动态下拉列表,请从后端发送列名。在
请尝试下面的查询
相关问题 更多 >
编程相关推荐