I am trying to figure out how to filter a ManyToMany field by value. In Django, it is as simple as queryset.filter(m2mfield__name), but I can\'t quite figure out what I am missi
Well, I found out what I was doing wrong. It was in the view. I had not declared filter_class on the view:
from rest_framework.generics import ListAPIView, RetrieveAPIView
from .serializers import StateSerializer
from .filters import StateFilter
class StateList(ListAPIView):
queryset = State.objects.all()
serializer_class = StateSerializer
filter_fields = ('name', 'cities')
filter_class = StateFilter # This was missing
I accidentally placed it on the serializer instead.