Fixed #6155 -- Fixed dumpdata to work with the default model manager (necessary

for the rare cases when the 'objects' manager might not even exist). Based on
a  patch from Michael Trier.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@6932 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Malcolm Tredinnick 2007-12-17 09:09:08 +00:00
parent 06482d4aa4
commit 3edf2ebd94
2 changed files with 8 additions and 1 deletions

View File

@ -38,7 +38,7 @@ class Command(BaseCommand):
objects = [] objects = []
for app in app_list: for app in app_list:
for model in get_models(app): for model in get_models(app):
objects.extend(model.objects.all()) objects.extend(model._default_manager.all())
try: try:
return serializers.serialize(format, objects, indent=indent) return serializers.serialize(format, objects, indent=indent)
except Exception, e: except Exception, e:

View File

@ -132,6 +132,13 @@ If no application name is provided, all installed applications will be dumped.
The output of ``dumpdata`` can be used as input for ``loaddata``. The output of ``dumpdata`` can be used as input for ``loaddata``.
Note that ``dumpdata`` uses the default manager on the mdoel for selecting the
records to dump. If you're using a `custom manager`_ as the default manager
and it filters some of the available records, not all of the objects will be
dumped.
.. _custom manager: ../model-api/#custom-managers
--format --format
~~~~~~~~ ~~~~~~~~