Reputation: 666
HTML
<form action="/tcgsave/" method="POST" onsubmit="return" >{% csrf_token %}
<p><label for="id_name">Name:</label> <input id="id_name" maxlength="60" name="name"type="text">{{testcaseName}} </input></p>
<input type="submit" />
</form>
views.py To save the form data
def tcgsave(request):
if request.method == 'POST':
testcase_name = request.POST.get('id_name')
print testcase_name
testcaseName = request.POST['id_name']
print testcaseName
testcase_name.save()
when i click on save button it give me null value for testcase_name
Upvotes: 0
Views: 36
Reputation: 10145
You should use name attribute of input instead of id:
request.POST.get('name')
in your case
Upvotes: 1