Will & Skill Developers

Will & Skill Developers


Thoughts, snippets and ideas from the team at Will & Skill AB, Stockholm.

Erik Svedin
Author

Share


Generating test data with django-autofixture

Erik SvedinErik Svedin

In a new django project, after setting up your models and views, you probably are eager to test out some of your apps behaviour with non static content. You can add models manually via the django admin panel. However this is probably a very time consuming task if your app is'nt super small.

Django autofixtures to the rescue!

Installing and setting up django-autofixtures

Installing and populating your database with test data is super easy:

  1. pip install django-autofixtures
  2. Make sure you add autoprefixer to your INSTALLED_APPS to use the management commands.
  3. Fill up your database with the management command: python manage.py loadtestdata app.MyModel:10

Where the number after the colon represent how many instances of the model you want to add.

For further reading check out the github page!
https://github.com/gregmuellegger/django-autofixture

Erik Svedin
Author

Erik Svedin

Comments