Saturday, October 25, 2014

Using fixtures in Django to import and export data

./manage.py dumpdata --indent 2 > all.json
and load it in again on the dev server (I use git to transfer it but there’s probably a cleaner approach):
./manage.py loaddata all.json

keep in mind that this will dump all the data from the database. if you want to limit the dump to a specific app you can do that. when loading if the data already exist in the database. you will get an error. so it is possible that you want to delete the tables before importing

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.