Skip to content

@list_route post cannot return serializer(qs, many=True) #2918

Closed
@sainttail

Description

@sainttail

I have a @list_route that look like this

@list_route(methods=['post'])
    def test(self, request):
        queryset = self.filter_queryset(self.get_queryset())
        serializer = self.get_serializer(queryset, many=True)
        return Response(serializer.data)

but when I try to POST to .../events/test/ via browsable API
calling without browsable API is working normally.

I got exactly same error message as #2607 (ListSerializer object is not iterable)

I don't know why this happen? because I want post action to return update objects
However, if i change to this @list_route(methods=['get']) or @list_route(methods=['patch']) it is working fine

My serializer class is a normal class that extends form ModelSerializer

class EventSerializer(serializers.ModelSerializer):
    class Meta:
        model = Event

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions