manage.py dumpdata --natural
will use a more durable representation of foreign keys. In django they are called “natural keys”. For example:
Permission.codename
is used in favour ofPermission.id
User.username
is used in favour ofUser.id
Read more: natural keys section in “serializing django objects”
Some other useful arguments for dumpdata
:
--indent=4
make it human readable.-e sessions
exclude session data-e admin
exclude history of admin actions on admin site-e contenttypes -e auth.Permission
exclude objects which are recreated automatically from schema every time duringsyncdb
. Only use it together with--natural
or else you might end up with badly aligned id numbers.