How to retrieve user editable table field value in django -


models.py  class invoice(models.model):         invoice_no=models.autofield(primary_key=true)         invoice_date_of_issue=models.datefield(null=false)         status=models.charfield(max_length=10,null=true)         discount=models.integerfield(null=true)   class invoice_details(models.model):         invoice_line_no=models.autofield(primary_key=true)         invoice_no=models.foreignkey('invoice',null=false)         details=models.charfield(max_length=255,null=true)         quantity=models.integerfield(null=false)         cost=models.floatfield(null=false)  view.py  def index(request):     data=invoice.objects.all()     form=invoiceform(request.post or none)     if form.is_valid():         save_it=form.save(commit=false)         save_it.save()         data1=invoice.objects.all()[::-1][:1]      return     render_to_response('invoice.html',locals(),context_instance=requestcontext(request)) return    render_to_response('invoice.html',locals(),context_instance=requestcontext(re  quest))  invoice.html <form action="" method="post"> <div style="float:right"> </div> {{ form.as_p }}{% csrf_token %} <input type="submit" value="add" name="">  <table id ="mytable">  <h3 align = "center"> enter invoice details below</h3>       <th>invoice_line_no</th>     <th>invoice_no</th>     <th>details</th>     <th>quantity</th>     <th>cost</th>  <tr>     <td><div contenteditable></div></td>     <td><div contenteditable></div></td>     <td><div contenteditable></div></td>     <td><div contenteditable></div></td>     <td><div contenteditable></div></td>      </tr>   </table> <button onclick="myfunction()">add new row</button> <script> function myfunction() {     var table = document.getelementbyid("mytable");     var row = table.insertrow(0);     var cell1 = row.insertcell(0);     var cell2 = row.insertcell(1);     var cell3 = row.insertcell(2);     var cell4 = row.insertcell(3);     var cell5 = row.insertcell(4);     cell1.innerhtml = "<div contenteditable></div>";     cell2.innerhtml = "<div contenteditable></div>";     cell3.innerhtml = "<div contenteditable></div>";     cell4.innerhtml = "<div contenteditable></div>";     cell5.innerhtml = "<div contenteditable></div>";  } </script>   

within invoice addform page..on submit.. have create editable table user insert invoice_details records. same invoice_no there can multiple invoice_details.using javascript able create new rows whenever user clicks add new row button. not aware how retrieve data invoice.html (editable table fields) view , save in database.

can me out this??

thanks in advance.


Comments