将一个表单共享数据拆分为多行

问题描述:

我正在寻找关于如何将大调查保存到多行(MySQL)的想法。任何帮助将不胜感激。我对python和django编程比较陌生。将一个表单共享数据拆分为多行

形式:

<form method="post"> 

<label for="InputOD1" class="col-sm-2 control-label">Order Number</label> 
<input type="text" id="InputOD1" name="InputOD1" placeholder="Order Number"> 

<label for="InputSA1" class="col-sm-2 control-label">Shipping Address</label> 
<input type="text" id="InputSA1" name="InputSA1" placeholder="Shipping Address"> 



<label for="InputFN1" class="col-sm-2 control-label">First Name</label> 
<input type="text" id="InputFN1" name="InputFN1" placeholder="Last Name"> 

<label for="InputLN1" class="col-sm-2 control-label">Last Name</label> 
<input type="text" id="InputLN1" name="InputLN1" placeholder="Last Name"> 

<label for="InputGR1" class="col-sm-2 control-label">Gender</label> 
<input type="text" id="InputGR1" name="InputGR1" placeholder="Gender> 



<label for="InputFN2" class="col-sm-2 control-label">First Name</label> 
<input type="text" id="InputFN2" name="InputFN2" placeholder="Last Name"> 

<label for="InputLN1" class="col-sm-2 control-label">Last Name</label> 
<input type="text" id="InputLN2" name="InputLN2" placeholder="Last Name"> 

<label for="InputGR1" class="col-sm-2 control-label">Gender</label> 
<input type="text" id="InputGR2" name="InputGR2" placeholder="Gender> 

<button type="submit" class="btn btn-default">Submit</button> 

</form> 

预期数据库结果:

Order Number, Shipping Address, First Name 1, Last Name 1, Gender 1 
Order Number, Shipping Address, First Name 2, Last Name 2, Gender 2 
.... 
Order Number, Shipping Address, First Name 5, Last Name 5, Gender 5 

对于这个任务,你应该使用django formsets