-
Notifications
You must be signed in to change notification settings - Fork 299
Closed
Labels
Description
Nested serializers don't use resource_name for the type. In the example below the type for the child would show something like nestedmodels.
class NestedSerializer(serializers.ModelSerializer):
resource_name = "pretty_nested"
class Meta:
model = NestedModel
class ParentSerializer(serializers.ModelSerializer):
nested = NestedSerializer(source='some_field', many=True)
class Meta:
model = ParentModelLooking at the code it looks like in utils.py the only function that performs the correct checks to get the type is get_resource_name(). All the other functions simply do something like relation_type = inflection.pluralize(relation_model.__name__).lower() without checking for a resource_name on the serializer as the docs suggest. I could submit a PR if it makes sense to put these checks in place everywhere. Ideally a function like get_related_resource_type() should act as a getter for type so that we don't see these inconsistencies.