Serializer class inside serializer #8010
Unanswered
jatindergit
asked this question in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
If I create serializer class inside serializer then it works fine
`
class ListCompanyAdminSerializer(serializers.ModelSerializer):
class CompanyUserSerializer(serializers.ModelSerializer):
company = CompanySerializer(read_only=True)
class RetrieveCompanyAdminSerializer(serializers.ModelSerializer):
class CompanyUserSerializer(serializers.ModelSerializer):
company = CompanySerializer(read_only=True)
positions = serializers.SerializerMethodField()
but drf-yasg gives error
drf_yasg.errors.SwaggerGenerationError: Schema for <class 'companies.api.v1.serializers.ListCompanyAdminSerializer.CompanyUserSerializer'> would override distinct serializer <class 'companies.api.v1.serializers.RetrieveCompanyAdminSerializer.CompanyUserSerializer'> because they implicitly share the same ref_name; explicitly set the ref_name attribute on both serializers' Meta classes
Do you think that I should not create serializer class inside serializer. Or they(drf_yasg) should should the bug.
Please suggest
Beta Was this translation helpful? Give feedback.
All reactions