Skip to main content

Populate your Django model from .xls file

Project description


Easy to use .xls Django model populator.

How to:

  1. First you need to install latest version of xlrd: pip install xlrd==1.1.0
  2. In order for this to work, you need exactly match your model's field names and xls's first row values(column names), like this:
    class Test(models.Model):
      one = models.CharField(max_length=150)
      two = models.CharField(max_length=150)
      three = models.CharField(max_length=150)
      four = models.CharField(max_length=150)
  3. Then you need to create file at the one level with your
  4. Put following code there:
    import os
    import django
    from django_xlspopulator.populator import Populator
    from YOURAPP.models import Test
    pop = Populator('C:/Users/Guido/Desktop/testfile.xls', Test)
    • Populator object takes three arguments:
      • path to the .xls file in form of a string
      • Django model object
      • Sheet number, int(0 by defaulft, specify it if you want to use other sheet)
  5. Run from the terminal and wait. For my old machine with SQLite it took 5 mins to populate model from file that had 4 columns and 10000 rows.

Project details

Release history Release notifications

This version


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django-xlspopulator, version 1.1
Filename, size & hash File type Python version Upload date
django_xlspopulator-1.1-py3-none-any.whl (3.6 kB) View hashes Wheel py3
django_xlspopulator-1.1.tar.gz (2.3 kB) View hashes Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page