You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PolymorphicResourceRelatedField serializer throws 'str' object has no attribute 'get_polymorphic_types', if the referenced serializer is declared before the referencing serializer.
class ASerializer(ModelSerializer):
...
class BSerializer(ModelSerializer):
A = PolymorphicResourceRelatedField(
'module.serializers.ASerializer',
) # <- this one raises 'str' object has no attribute 'get_polymorphic_types', to avoid it we have to reference the class directly ASerializer
C = PolymorphicResourceRelatedField(
'module.serializers.ASerializer', # <- this one does not raise error
)
class CSerializer(ModelSerializer):
...
'module.serializers.ASerializer' should be the preferred way of referencing other serializers to avoid circular imports.