找回密码
 立即注册

扫一扫,访问微社区

QQ登录

只需一步,快速开始

查看: 1570|回复: 0

[求助] django的查询页面问题

2

主题

4

帖子

4

积分

贫民

积分
4
woailp___2005 发表于 2019-3-16 11:08:30 | 显示全部楼层 |阅读模式
我的view.py的代码是这样的
def findinfo(request):
    return render(request,'findinfo.html')

def findresult(request):
    items = []
    testline = {}
    for i in range(10):
        testline['name'] = "nxy"
        testline['id'] = "123456"
        items.append(testline.copy())

    return render(request,'findinfo.html',{'items':items})


findinfo.html模板是这样的

<!DOCTYPE html>
<html>
<head>
        <title>查询页面</title>
</head>
<body>


<form align="center" action="/findresult/" method="get">
查询条件: <input type="text" id="name" name="name"> <br><br>
    <button  type="button" id='find'>查询</button>
</br></br>

</form>

<table class="gridtable" align="center" id="pstable" border="1">

<thead>
            <tr>
                <th>姓名</th>
                <th>编号</th>
            </tr>
</thead>

<tbody>
{%for item in items%}
<tr>
                <td>{{item.name}}</td>
                <td>{{item.id}}</td>
</tr>
{% endfor %}       
</tbody>

</table>
</body>
</html>

<script src="http://apps.bdimg.com/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
    $(document).ready(function(){
      $("#find").click(function(){
        $.get("/findresult/",{'name':name},
                function(ret){
            $('#pstable').html(ret)
        })
      });
    });
</script>


打开页面开始显示:
图片1.png
点击查询后显示是这个样子的:
图片2.png
table里又嵌套了查询按钮,这个怎么解决啊
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表