Change: Django Dumpdata

created on Oct. 16, 2012, 8:06 p.m. by Hevok & updated on Oct. 16, 2012, 8:06 p.m. by Hevok

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

$ python manage.py 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 manage.py syncdb
$ python manage.py migrate # If using south
$ python manage.py 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

Comment: Updated entry

See entry | Admin

Comment on This Data Unit