我希望我的搜索结果显示在另一个 html 文件中。我的模板如下:
<html>
<head></head>
<body>
<div id="div1">
{% for i in var1 %}
{{i.name}}<br>
{% endfor %}
</div>
<form action="searchresult.html" method="post">{% csrf_token %}
<input type="text" name="search1">
<input type="submit" id="click1" value="search">
</form>
</body>
</html>
视图.py
def search(request):
var = ""
if request.method=='POST':
s1 = request.POST.get("search1")
var = form1.objects.all().filter(keyskills=s1)
return render(request,"search.html",{'var1':var})
模型.py
class form1(models.Model):
name = models.CharField(max_length=20)
qualification = models.CharField(max_length=20)
keyskills = models.CharField(max_length=50)
def __unicode__(self):
return self.name,self.qualification,self.keyskills
我的结果在同一页面中显示了搜索详细信息。相反,我希望它显示在searchresult.html
. 我已经写了searchresult.html
表单标签的作用。请给我你的建议。