rsinger86 / drf-flex-fields

Dynamically set fields and expand nested resources in Django REST Framework serializers.
MIT License
740 stars 61 forks source link

fix: TypeError: _get_expandable_fields() takes 1 positional argument … #101

Closed michaelschem closed 2 years ago

michaelschem commented 2 years ago

…but 2 were given

michaelschem commented 2 years ago

I'm trying out the FlexFieldsFilterBackend. Since I don't want to make it the project default, I've specified it tin the specific viewset that I'm using.

class SkuViewSet(FlexFieldsMixin, viewsets.ReadOnlyModelViewSet):
    from rest_flex_fields.filter_backends import FlexFieldsFilterBackend
    serializer_class = ExSkuSerializer
    queryset = Sku.objects.none()
    filter_backends = [FlexFieldsFilterBackend]

My Serializer is defined as follows:

class ExSkuSerializer(FlexFieldsModelSerializer):
    class Meta:
        model = Sku
        fields = ['uid', 'name', 'slug', 'max_qty_per_order']

Unfortunately I get a type error TypeError: _get_expandable_fields() takes 1 positional argument but 2 were given.

This PR seems to fix that issue by making the method static just like the one above it which I think probably was intended.

rsinger86 commented 2 years ago

thanks!