这是我的index.html
<html>
<body>
<p>Please select Team from below:</p>
<form action="teamspage/" method="post">{% csrf_token %}
<select name="teams">
<option value="astra">Astra</option>
<option value="everest">Everest</option>
<option value="pulse">Pulse</option>
<option value="gravity">Gravity</option>
</select>
<br><br>
<input type="submit">
</form>
</body>
</html>
views.py:
@csrf_exempt
def index(request):
template = loader.get_template('piplanner/index.html')
context = {
}
return HttpResponse(template.render(context, request))
def teamspage(request):
if request.method == "POST":
return HttpResponse("Got it new team")
urls.py
urlpatterns = [
url(r'^index/', include('piplanner.urls')),
url(r'^admin/', admin.site.urls),
url(r'^teamspage/', include('piplanner.urls')),
]
piplanner网址:
urlpatterns = [
url(r'^$', views.index, name='index'),
url(r'^$', views.teamspage, name='teamspage'),
]
在提交请求时,不会进入团队页面视图。请让我知道代码有什么问题吗? 我正在尝试获取返回下拉列表形式的方法,并在选择值上返回到teampage网址