title: Django, How do I write views when form submission using ajax jquery?
body: <p>I have a model here</p>
  
  <pre><code>class personaldetails(models.Model):
      fname=models.CharField(max_length=30)
      lname=models.CharField(max_length=30)
      email=models.CharField(max_length=30)
      mbleno=models.IntegerField()
      maritalstatus=models.CharField(max_length=30)
      currentindustry=models.CharField(max_length=30)
      functionalarea=models.CharField(max_length=30)
      annualsalary=models.CharField(max_length=30)
  </code></pre>
  
  <p>views.py</p>
  
  <pre><code>def personalinformation(request):
      print "hello"
      if request.method=='POST':
          print "hi"
          fn=request.POST.get('fname')
          print fn
          ln=request.POST.getlist('lname')
          email=request.POST.getlist('email')
          mno=request.POST.getlist('mbleno')
          ms=request.POST.getlist('maritalstatus')
          ci=request.POST.getlist('currentindustry')
          fc=request.POST.getlist('functionalarea')
          ans=request.POST.getlist('annualsalary')
          personaldetails(fname=fn,lname=ln,email=email,mbleno=mno,maritalstatus=ms,currentindustry=ci,functionalarea=fc,annualsalary=ans).save()
          s="example"
          return HttpResponse(s,mimetype='application/json')
      return render(request,"itechdisplay.html")      
  </code></pre>
  
  <p>my itechdisplay.html</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;script src="http://code.jquery.com/jquery-1.10.1.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  $(document).ready(function(){
      $('#formid').submit(function(){
      $.ajax({
           type:$(this).attr('method'),
          data:$(this).serialize(),
          url:'/personalinformation/',
          success:function(data) {
          alert($(data));
  }
    });
      });
  });
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form action="." id="formid" method="post"&gt;{% csrf_token %}
  
  Firstname:&lt;input type="text" id="firstname" name="input1"&gt;&lt;br&gt;
  Lastname:&lt;input type="text" id="lastname" name="input2"&gt;&lt;br&gt;
  e-mail:&lt;input type="text" id="email" name="input4"&gt;&lt;br&gt;
  mobileno:&lt;input type="text" id="mobleno" name="input5"&gt;&lt;br&gt;
  Maital status:&lt;select id="maritalstatus"&gt;
  &lt;option value="s1" selected&gt;single&lt;/option&gt;
  &lt;option value="s1"&gt;married&lt;/option&gt;
  &lt;option value="s1"&gt;divorsed&lt;/option&gt;
  &lt;option value="s1"&gt;other&lt;/option&gt;
  &lt;/select&gt;&lt;br&gt;
  Current industry&lt;select id="currentindustry"&gt;
  &lt;option value="s1"&gt;IT-software/software sevices&lt;/option&gt;
  &lt;option value="s1" selected&gt;it-hardware/networking&lt;/option&gt;
  &lt;option value="s1"&gt;insurance&lt;/option&gt;
  &lt;option value="s1"&gt;other&lt;/option&gt;
  &lt;/select&gt;&lt;br&gt;
  Functional area:&lt;select id="functionalarea"&gt;
  &lt;option value="s1" selected&gt;IT-software&lt;/option&gt;
  &lt;option value="s1"&gt;it-hardware&lt;/option&gt;
  &lt;option value="s1"&gt;agent&lt;/option&gt;
  &lt;option value="s1"&gt;other&lt;/option&gt;
  &lt;/select&gt;&lt;br&gt;
  Annual salary&lt;select id="annualsalary"&gt;
  &lt;optgroup label="Hour wise"&gt;
  &lt;option value="s1"&gt;less than 40$/hr&lt;/option&gt;
  &lt;option value="s1"&gt;40-50$/hr&lt;/option&gt;
  &lt;option value="s1"&gt;50-60$/hr&lt;/option&gt;
  &lt;option value="s1"&gt;above 60$&lt;/option&gt;
  &lt;/optgroup&gt;
  &lt;optgroup label="month wise"&gt;
  &lt;option value="s1"&gt;less than 20,000$&lt;/option&gt;
  &lt;option value="s1"&gt;20-30,000$&lt;/option&gt;
  &lt;option value="s1"&gt;30-40,0000$&lt;/option&gt;
  &lt;option value="s1"&gt;above 40,000$&lt;/option&gt;
  &lt;/optgroup&gt;
  &lt;/select&gt;&lt;br&gt;
  &lt;input type="submit" id="save1" value="save"&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I have written a model.
  In my template I want to use post method. When I submit a form I want the details to be moved to views and store it in the database and retrieve it to be displayed. I don't know know how to write the views to bring the data from template. I tried as I mentioned above.
  But I get this error as follows</p>
  
  <pre><code>int() argument must be a string or a number, not 'list'
  </code></pre>
  
  <p>in a following line of my views.py</p>
  
  <pre><code>personaldetails(fname=fn,lname=ln,email=email,mbleno=mno,maritalstatus=ms,currentindustry=ci,functionalarea=fc,annualsalary=ans).save()
  </code></pre>
  
  <p>How to write the view? Any approaches can be appreciated.. thanks in advance</p>