Tool for automatically creating data for django model

Question:

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?

Asked By: Joe

||

Answers:

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/

Answered By: arie

http://www.generatedata.com/

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

Answered By: Daniel DiPaolo

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.
Answered By: Josh Smeaton

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.

Answered By: MaDeuce

Django-eadred was designed for "generating sample data."

As its docs state

eadred allows you to programmatically generate the data using model makers, factories, fixtures, random seeds—whatever your needs are.

Additionally, eadred provides library functions to make generating data easier.

Answered By: Private

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.

Answered By: Naaim Iss