When the mixin FilterSerializerByOrgManaged is used to filter the organization field in a serializer fields, if the field is set to read_only, then no queryset attribute is found in PrimaryKey, due to which it raises an AttributeError error as 'NoneType' object has no attribute 'filter'
We will probably need to filter the field only when it is not set to read_only.
https://github.com/openwisp/openwisp-users/blob/4bb0310eaefc75006bd802100d36a09a1fb9af9b/openwisp_users/api/mixins.py#L141-L145
When the mixin
FilterSerializerByOrgManaged
is used to filter theorganization
field in a serializer fields, if the field is set toread_only
, then noqueryset
attribute is found inPrimaryKey
, due to which it raises anAttributeError
error as'NoneType' object has no attribute 'filter'
We will probably need to filter the field only when it is not set to
read_only
.PS: I found this issue while working on the REST API for the
topology
module. https://github.com/openwisp/openwisp-network-topology/pull/113The error can be found in the CI of this build. https://github.com/openwisp/openwisp-network-topology/pull/113/checks?check_run_id=3282685073