Moved get_serializer() call in dumpdata command.
Moved the get_serializer() call within the condition that checks public serializers. This will allow exceptions other than SerializerDoesNotExist to be raised in order to provide the caller with useful information, e.g when pyyaml is not installed.
This commit is contained in:
parent
c72392dab4
commit
076cf131ec
|
@ -106,11 +106,11 @@ class Command(BaseCommand):
|
||||||
# Check that the serialization format exists; this is a shortcut to
|
# Check that the serialization format exists; this is a shortcut to
|
||||||
# avoid collating all the objects and _then_ failing.
|
# avoid collating all the objects and _then_ failing.
|
||||||
if format not in serializers.get_public_serializer_formats():
|
if format not in serializers.get_public_serializer_formats():
|
||||||
raise CommandError("Unknown serialization format: %s" % format)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
serializers.get_serializer(format)
|
serializers.get_serializer(format)
|
||||||
except KeyError:
|
except serializers.SerializerDoesNotExist:
|
||||||
|
pass
|
||||||
|
|
||||||
raise CommandError("Unknown serialization format: %s" % format)
|
raise CommandError("Unknown serialization format: %s" % format)
|
||||||
|
|
||||||
def get_objects():
|
def get_objects():
|
||||||
|
|
Loading…
Reference in New Issue