django-rest-framework-bulk icon indicating copy to clipboard operation
django-rest-framework-bulk copied to clipboard

UUIDs are not handled

Open melinath opened this issue 7 years ago • 4 comments

BulkSerializerMixin uses get_value() to get the id of an object, but doesn't use to_internal_value() to convert the id to the proper internal value. This works fine for integer ids, but it breaks for UUIDs because the all_validated_data_by_id in BulkListSerializer.update constructs a dict by string id and then tries to get values for instance ids (which are UUIDs and thus not in the dictionary.)

melinath avatar Sep 13 '17 15:09 melinath

Workaround / solution is to copy BulkSerializerMixin into your app and replace this line:

id_value = id_field.get_value(data)

with this one:

id_value = id_field.to_internal_value(id_field.get_value(data))

melinath avatar Sep 13 '17 15:09 melinath

Thank you, solved my problem!

hudsonbrendon avatar Jun 20 '18 03:06 hudsonbrendon

Thank you, solved my problem!

rodrigo-xavier avatar Sep 04 '19 12:09 rodrigo-xavier

This also solved my problem bulk_update & bulk_partial_update fail, but others work fine:

python3.8/site-packages/rest_framework/serializers.py", line 986, in update for attr, value in validated_data.items(): AttributeError: 'NoneType' object has no attribute 'items' [17/Mar/2021 22:17:04] "PUT /api/ruleset/ HTTP/1.1" 500 29444

zbragg-s5 avatar Mar 17 '21 22:03 zbragg-s5