Alex Rivera | Logout

Tool for automatically creating data for django model

Asked 2011-04-12T22:23:00.420
32

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?

Edit
Report

1 Answer

8

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 2011-04-12T22:53:58.560

Your Answer