Tool for automatically creating data for django model

18,072

Solution 1

I haven't used it myself, but django-autofixture looks pretty much like what you are after.

Other similar apps are listed in this grid: https://www.djangopackages.com/grids/g/fixtures/

Solution 2

http://www.generatedata.com/

This has some pretty nice generic field types that aren't Django-specific

Solution 3

django-dilla was built specifically to populate your django models with 'spam' data. The below is taken directly from the site example after defining some settings. It will even let you define your own 'spammers' that will generate data in a particular format.

$ ./manage.py run_dilla --cycles=100
Dilla is going to spam your database. Do you wish to proceed? (Y/N)Y
Dilla finished!
    2 app(s) spammed 900 row(s) affected, 2498 field(s) filled, \
    502 field(s) ommited.

Solution 4

Checkout django-mockups: https://github.com/sorl/django-mockups

It will automatically generate data for any model, including foreign key and many to many. You can run it as-is out-of-the-box, giving it the maximum depth for relationships, and it will generate data fully exploiting your model.

You can also write your own generators and factories to get fine-grained control over relationships and to generate data specific to your application, rather than just random data. I just got through using it on a project, and it saved me literally days of work setting up test data.

Solution 5

If the question is still actual you may try package django-mimesis. It offers to fill database with dummy data in different languages according to types of fields. Also you may download some pictures automatically using specified topics. Not always works great, sometime pictures' topics are mismatched. But for me it is enough.

Share:
18,072
Joe
Author by

Joe

Updated on June 03, 2022

Comments

  • Joe
    Joe almost 2 years

    I want to test models which are explained in the Django tutorial. Is there an automatic way to fill them with sample data? It's one of them:

    class Book(models.Model):
        name = models.CharField(max_length=300)
        pages = models.IntegerField()
        price = models.DecimalField(max_digits=10, decimal_places=2)
        rating = models.FloatField()
        authors = models.ManyToManyField(Author)
        publisher = models.ForeignKey(Publisher, on_delete=models.CASCADE)
        pubdate = models.DateField()
    

    Any suggestion?