Reputation: 1270
I create a page with text inside a element:
<form id='myform' action="save/" method="POST">
<td id='test'>test</td>
<td><input type="text" size="20" id="test2" name="test2"></td>
</form>
and I change test element by javascript function:
<script language="javascript">
function edit()
{
var x= document.getElementById('test');
x.innerHTML='<input type="text" name="test1" id="test1" value="test">';
}
</script>
now I submit current form with post method, I can get value test2 in django view:
print(request.POST['test2'])
but when I get value test1 (javascript generate new input element), it show Exception :
print(request.POST['test1'])
MultiValueDictKeyError at /~/save/ 'test1' Request Method: POST Django Version: 2.0.5 Exception Type: MultiValueDictKeyError Exception Value:'test1' can anyone helps me? very thanks!
Upvotes: 0
Views: 84
Reputation: 26
Are you sure that you have called this function?
Before you send the POST request, have you checked in the HTML source code that your 'test1' input has been renamed to 'test2'?
Upvotes: 0