Single objects are not serialized as JSON strings
|Reported by:||stefan.freyr@…||Owned by:||adrian|
|Cc:||Triage Stage:||Design decision needed|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
It's a bit unintuitive in my opinion that the JSON serializer only handles lists of objects.
For example, the follwing two liner will result in a TypeError ("iteration over non-sequence):
my_object = MyModel.objects.all() data = serializers.serialize("json", my_object)
While changing the first line to:
my_object = MyModel.objects.all()[:1]
Results in a runnable program.
Shouldn't the JSON serializer be able to serialize single instances?