Django Dumpdata

Django allows to dump put a database via common interface: ::

$ python dumpdata --all --natural > all.json

The natural flag helps to preserve some things like contenttypes and permissions

This data can be incorporated into database like this: ::

$ python syncdb
$ python migrate # If using south
$ python loaddata all.json

To prevent issues with initial data in django-dev (1.5) version the --not-initial-data flag can eb set. Otherwise on for instance Postgres surn the following before loaddata: ::

=# delete from auth_group_permissions; delete from auth_permission; delete from django_admin_log; delete_content_type;

Edit tutorial

Comment on This Data Unit