Django 1.8 handwritten form no POST data -


i've become frustrated problem i'm having. have large form that's hand-written (not using django's forms), , trying access data inputs in views (in case, inputs posting, others weren't).

leaving specifics of form aside since there many things @ play, in troubleshooting process wrote simplest form think of, , getting no post data besides csrf_token.

i have no idea why be, since similar (and more complex) works fine on several other django projects i'm running. example, tried action="" no avail. there incredibly obvious i'm missing?

here's html:

<!doctype html>   <html>      <head>   </head>      <body>   <form method="post" id="theform" action="/simpleform/">{% csrf_token %}           <input type="text" id="thetext" value="where i?" />           <input type="hidden" id="hiddeninput" value="i don't exist" />           <input type="submit" />      </form>      </body>      </html>

here simple view checking data:

from django.shortcuts import render  def simpleform(request):      if (request.method == 'post'):          print('in post')         print(request.post)          in request.post.keys():              print('key: {0} value: {1}'.format(i, request.post[i]))          return render(request, 'simpleform.html')      else:          return render(request, 'simpleform.html') 

you're missing 'name' attribute of tags in html form. without those, django not add them request.post

<form method="post" id="theform" action="/simpleform/">{% csrf_token %}          <input type="text" id="thetext" name="mytext" value="where i?" />          <input type="hidden" id="hiddeninput" name="myhidden" value="i don't exist" />          <input type="submit" />  

Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -