Skip to content
This repository has been archived by the owner on Jan 11, 2021. It is now read-only.

Fix child field instantiation with missing arguments #459

Merged
merged 1 commit into from
Jun 18, 2016

Conversation

daluege
Copy link
Contributor

@daluege daluege commented Jun 17, 2016

docgenerator.py:

    def _find_field_serializers(self, serializers, found_serializers=set()):
        """
        Returns set of serializers discovered from fields
        """
        ...
            fields = serializer().get_fields()

provokes an instantiation error (AssertionError: Theslug_fieldargument is required.), when a ListSerializer is used with a child field that is not a serializer and that expects mandatory arguments in its constructor.

django-rest-swagger wrongly assumes the child to be a serializer and thus to be callable without arguments.

Example:

class ProfileSerializer(serializers.ModelSerializer):
    interests = serializers.ListSerializer(child=serializers.SlugRelatedField(slug_field='title', queryset=Discipline.objects.all()))

Therefore, add a test for child to inherit from BaseSerializer.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants