title: How to import xls/xlsx in django models?
body: <p>I'm using django-excel to do this function.</p>
  
  <p>This is my view.py</p>
  
  <pre><code>def import_data(request):
      if request.method == "POST":
          form = UploadFileForm(request.POST, request.FILES)
          if form.is_valid():
              request.FILES['file'].save_book_to_database(
                 models=['contoh_upload'],
                 initializers=[None,0],
                 mapdicts=['id','nama','kelas']
               )
              message = "your upload has been uploaded "
              return render(request, 'kastransaksi/transaksi_formupload.html', {'message': message})
          else:
              message = "Failed Upluad data"
              return render(request, 'kastransaksi/transaksi_formupload.html', {'form': form, 'message': message})
      else:
          form = UploadFileForm()
          return render(request, 'kastransaksi/transaksi_formupload.html', {'form': form})
  </code></pre>
  
  <p>this is my models.py</p>
  
  <pre><code>class contoh_upload(models.Model):
      nama = models.CharField(max_length=10, null=True, blank=True)
      kelas = models.CharField(max_length=10, null=True, blank=True)
  </code></pre>
  
  <p>and this is my template.html</p>
  
  <pre><code>&lt;div class="alert-success"&gt;{{ message }}&lt;/div&gt;
  &lt;form action="" method="post" enctype="multipart/form-data"&gt;
      {% csrf_token %}
      &lt;!-- &lt;input type="file" name="excel_file"&gt; --&gt;
      {{ form }}
      &lt;input type="submit" name="input_button" value="UPLOAD" class="btn btn-primary"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>but I get this error:    </p>
  
  <blockquote>
    <p>Traceback:</p>
    
    <p>File
    "C:\Python27\lib\site-packages\django-1.10.4-py2.7.egg\django\core\handlers\exception.py"
    in inner
      39.             response = get_response(request)</p>
    
    <p>File
    "C:\Python27\lib\site-packages\django-1.10.4-py2.7.egg\django\core\handlers\base.py"
    in _legacy_get_response
      249.             response = self._get_response(request)</p>
    
    <p>File
    "C:\Python27\lib\site-packages\django-1.10.4-py2.7.egg\django\core\handlers\base.py"
    in _get_response
      187.                 response = self.process_exception_by_middleware(e, request)</p>
    
    <p>File
    "C:\Python27\lib\site-packages\django-1.10.4-py2.7.egg\django\core\handlers\base.py"
    in _get_response
      185.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)</p>
    
    <p>File "C:\Users\Lenovo\OneDrive\siswa\transaksi_kas\views.py" in
    import_data
      165.                 models=[(contoh_upload, ['nama', 'kelas'], None, 0)],</p>
    
    <p>File "C:\Python27\lib\site-packages\django_excel__init__.py" in
    save_book_to_database
      61.         pe.save_book_as(**params)</p>
    
    <p>File "C:\Python27\lib\site-packages\pyexcel\core.py" in save_book_as
      224.     return sources.save_book(book, **dest_keywords)</p>
    
    <p>File "C:\Python27\lib\site-packages\pyexcel\sources__init__.py" in
    save_book
      46.     return _save_any(source, book)</p>
    
    <p>File "C:\Python27\lib\site-packages\pyexcel\sources__init__.py" in
    _save_any
      50.     source.write_data(instance)</p>
    
    <p>File "C:\Python27\lib\site-packages\pyexcel\sources\database.py" in
    write_data
      248.                 sheet.name_columns_by_row(0)</p>
    
    <p>File "C:\Python27\lib\site-packages\pyexcel\sheets\sheet.py" in
    name_columns_by_row
      140.         self.__column_names = make_names_unique(self.row_at(row_index))</p>
    
    <p>File "C:\Python27\lib\site-packages\pyexcel\sheets\matrix.py" in
    row_at
      162.             raise IndexError(constants.MESSAGE_INDEX_OUT_OF_RANGE)</p>
    
    <p>Exception Type: IndexError at /transaksi/import_form/ Exception Value:
    Index out of range</p>
  </blockquote>