Django无法发布数据

时间:2019-11-25 11:35:52

标签: python html django python-2.7

这是我的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网址

0 个答案:

没有答案