...私はジャンゴでの新たなんだと、私はこの問題を持っている:私は私のドロップダウンリストで選択したデータを表示したい場合には、それは動作しません...これは、コードDjangoのドロップダウンPOST
指標であります.htmlの
<form method="post" action="/getdata/">
<select name="Lista">
<option selected="selected" disabled>Objects on page:</option>
<option value="10">10</option>
<option value="20">20</option>
<option value="30">30</option>
<option value="40">40</option>
<option value="50">50</option>
</select>
<input type="submit" value="Select">
</form>
views.py
DEF指数(要求):
if request.method == 'POST':
Lista = request.POST.get('Lista')
print Lista
context = {
Lista: 'Lista'
}
return render(request, 'showdata.html', context)
else:
template = loader.get_template('index.html')
return HttpResponse(template.render())
getdata.html
<form method="post" action="/getdata/">
<table>
<tr>
<td>Numero:</td>
<td><strong>{{ Lista }}</strong></td>
</table>
</form>
urls.py
urlpatterns = [
url(r'^admin/', admin.site.urls),
# url(r'^', views.home, name="home"),
#define the url getdata that we have written inside form
url(r'^getdata/', views.index),
# defining the view for root URL
url(r'^$', views.index),
]
私は、サーバーを実行したときに私は、次の "ヌメロ:" を参照してください...あなたの助けのための
感謝を選択し、任意の数なしを...
。フォームは '/ getdata /'に送信されますが、 'getdata.html'テンプレートをレンダリングするURLのビューは表示されていません。 – Alasdair
プリントは端末で動作します...私はPOSTデータを見ることができますが、ブラウザは私にデータを表示しません –
私はフォームを使用しません.... –