Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 67497

django not able to post data

$
0
0

This is my 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")
urlpatterns = [
        url(r'^index/', include('piplanner.urls')),
        url(r'^admin/', admin.site.urls),
        url(r'^teamspage/', include('piplanner.urls')),
    ]

On submit request is not going to teamspage view. Please let me know what is wrong with code? I am trying get method which returns form of drop down and on selection value it should go to teamspage url


Viewing all articles
Browse latest Browse all 67497

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>