Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use Django dumpdata to dump a subset of overall data?

I'm trying to use dumpdata to generate JSON for a database that is sufficiently large for django to take a long, long time to output. Is there any way to dump only a subset of the fields; say, 100, for testing?

I'm using MySQL and Django 1.0.

like image 553
thebossman Avatar asked Apr 28 '10 23:04

thebossman


2 Answers

A 3rd party django app, django-test-utils contains a makefixture command implementation which is basically a smarter dumpdata. You can specify exact model names with ID ranges to export (and it will follow related objects) Example: manage.py makefixture --format=xml --indent=4 proj.appname.modelname[1:101] > test.xml

like image 153
Botond Béres Avatar answered Sep 27 '22 22:09

Botond Béres


See also Django Selective Dumpdata which suggests Django Fixture Magic

like image 25
rrauenza Avatar answered Sep 27 '22 23:09

rrauenza