所以我在views.py
中有这行代码def display_agao(request):
query_agao = Butuan_Parcel.objects.filter(newpin="162-01-0001-002-29")
djf = Django.Django(geodjango='geom',properties=['id','newpin'])
geoj = GeoJSON.GeoJSON()
butuan_agao = geoj.encode(djf.decode(query_agao.transform(3857)))
query_subclass = tbl_subclass.objects.all()
return render(request,"index1.html",{'butuan_agao': butuan_agao, 'query_agao':query_agao,'query_subclass':query_subclass})
我想从html文件中获取值,以便我可以获取newpin取决于用户查询并能够从地图中显示图层。
<form action="." method="GET">
<select name="q">
{% for parcel in query_agao %}
<option type="text" value="{{ parcel.newpin }}">{{ parcel.newpin }}</option>
{% endfor %}
</select>
<input type="submit" value="Search">
</form>
上面的示例表单......
答案 0 :(得分:0)
您可以从html表单中获取值以查看使用request
arg,
def my_view(request, ):
search_term = request.GET.get("q", None) #--> q means "name" of select box in html.
# use search_term whatever you wants.