3 de febrero de 2011

Django: Dump your database contents to(SQL data) into an xml file

To dump all the data in your Django project's db into a nice xml fixture, just run the following command:
python manage.py dumpdata --format=xml APP_NAME > SOME_FIXTURES_FOLDER/APP_NAME/initial_data.xml
Update:

As Fabi[1] correctly (and violently jeje :-P) pointed out, json is much cooler:

python manage.py dumpdata --indent=4 data.json

[1] @caffeineGalli at Twitter and his site: http://from-the-cloud.com/

No hay comentarios: