em1208 / adrf

Async support for Django REST framework
Other
449 stars 25 forks source link

Determine if a field is async or not by the presence of ato_representation. #46

Closed tbeadle closed 1 month ago

tbeadle commented 2 months ago

Don't hard-code the list of DRF_FIELDS--this was missing things like SerializerMethodField, ManyRelatedField, and ReadOnlyField.

Vonfry commented 2 months ago

I meet the same issue with ManyRelatedField recently.

Vonfry commented 2 months ago

We cannot use sync version for ManyRelatedField simply like this pr, because the internal methods call some db actions with sync version, which is not allowed.

A temporary solution is that defines a custom serializer for your many to many fields with a (custom) list serializer, and override acreate and aupdate in the outset serializer to handle these operations on those fields.

em1208 commented 1 month ago

I'm OK to merge this PR to avoid the hardcoding of the fields but there are no tests for all the fields in DRF at the moment so I expect some minor issues which I will look into when I have time. I already merged @Vonfry PR 48 to fix the issue with the many to many field. Thanks again to both!