Django Dumpdata

Created on Oct. 16, 2012, 8:06 p.m. by Hevok & updated by Hevok on May 2, 2013, 5:24 p.m.

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;

Tags: database
Categories: Tutorial
Parent: Web Framework

Update entry (Admin) | See changes

Comment on This Data Unit