Skip to content

Commit 9afc51b

Browse files
committed
Modified the internal dumpdata implementation to return the dumped data, rather than just printing to screen.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4715 bcc190cf-cafb-0310-a4f2-bffc1f526a37
1 parent 9f0c545 commit 9afc51b

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

django/core/management.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1436,7 +1436,7 @@ def dump_data(app_labels, format='json', indent=None):
14361436
for model in get_models(app):
14371437
objects.extend(model.objects.all())
14381438
try:
1439-
print serializers.serialize(format, objects, indent=indent)
1439+
return serializers.serialize(format, objects, indent=indent)
14401440
except Exception, e:
14411441
sys.stderr.write(style.ERROR("Unable to serialize database: %s\n" % e))
14421442
dump_data.help_doc = 'Output the contents of the database as a fixture of the given format'
@@ -1582,7 +1582,7 @@ def execute_from_command_line(action_mapping=DEFAULT_ACTION_MAPPING, argv=None):
15821582
parser.print_usage_and_exit()
15831583
elif action == 'dumpdata':
15841584
try:
1585-
action_mapping[action](args[1:], options.format, options.indent)
1585+
print action_mapping[action](args[1:], options.format, options.indent)
15861586
except IndexError:
15871587
parser.print_usage_and_exit()
15881588
elif action in ('startapp', 'startproject'):

tests/modeltests/fixtures/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class Meta:
7373
[<Article: Time to reform copyright>, <Article: Poker has no place on ESPN>, <Article: Python program becomes self aware>]
7474
7575
# Dump the current contents of the database as a JSON fixture
76-
>>> management.dump_data(['fixtures'], format='json')
76+
>>> print management.dump_data(['fixtures'], format='json')
7777
[{"pk": "3", "model": "fixtures.article", "fields": {"headline": "Time to reform copyright", "pub_date": "2006-06-16 13:00:00"}}, {"pk": "2", "model": "fixtures.article", "fields": {"headline": "Poker has no place on ESPN", "pub_date": "2006-06-16 12:00:00"}}, {"pk": "1", "model": "fixtures.article", "fields": {"headline": "Python program becomes self aware", "pub_date": "2006-06-16 11:00:00"}}]
7878
"""}
7979

0 commit comments

Comments
 (0)