Python django将参数从模板传递到bash脚本
我试图在模板中有一个输入字段,用户输入一个查询,该查询将转到views.py 从这里开始,我接受查询并将其作为参数传递给bash脚本 这就是我现在所拥有的。 views.py base.htmlPython django将参数从模板传递到bash脚本,python,mysql,django,bash,Python,Mysql,Django,Bash,我试图在模板中有一个输入字段,用户输入一个查询,该查询将转到views.py 从这里开始,我接受查询并将其作为参数传递给bash脚本 这就是我现在所拥有的。 views.py base.html 我被困在这里。我不知道我是喊request.POST还是其他更简单的东西…因为我不想使用表单。我通过在html模板中创建脚本来解决它 <script> $(".opener").click(function () { var thead = $("#mytable")
我被困在这里。我不知道我是喊request.POST还是其他更简单的东西…因为我不想使用表单。我通过在html模板中创建脚本来解决它
<script>
$(".opener").click(function () {
var thead = $("#mytable").find("thead");
thead.find('th').last().remove();
thead = thead.html();
var row = $(this).parents('tr');
row.find('td').last().remove();
row = row.html();
var table = $(document.createElement('table'));
table.append('<thead>' + thead + '</thead>');
table.append('<tbody><tr>' + row + '</tr></tbody>')
$(".modal").html("").append(table);
$(".modal").dialog({width: 'auto', position: 'top'});
});
</script>
你的意思是你不知道如何用查询结果填充表单吗?我只想在该输入字段中输入查询,然后查询转到bash脚本…但是页面不工作…我得到这个值错误:view crawler.views.home没有返回HttpResponse对象。它返回的是无。可能是安装问题,即某些内容未指向正确的位置。其他页面工作吗?是的…一切正常…包括调用bash脚本。。。我甚至用一个HttpResponse返回测试了home函数……没有request.methodNo,看起来你的base.html已经在向视图发送一些东西了。Try是检查表单是否正确的有效方法,就像我在上面发送的帖子一样。
<form action="/" method="post">
{% csrf_token %}
<input type="hidden" name="query" value="{{ input }}">
<input type="submit" value="Submit">
</form>
<script>
$(".opener").click(function () {
var thead = $("#mytable").find("thead");
thead.find('th').last().remove();
thead = thead.html();
var row = $(this).parents('tr');
row.find('td').last().remove();
row = row.html();
var table = $(document.createElement('table'));
table.append('<thead>' + thead + '</thead>');
table.append('<tbody><tr>' + row + '</tr></tbody>')
$(".modal").html("").append(table);
$(".modal").dialog({width: 'auto', position: 'top'});
});
</script>