from rest_framework import viewsets

from .models import Farmer
from .serializers import FarmerSerializer


class FarmerViewSet(viewsets.ReadOnlyModelViewSet):
    queryset = Farmer.objects.all()
    serializer_class = FarmerSerializer

from rest_framework import viewsets

from .models import Farmer
from .serializers import FarmerSerializer


class FarmerViewSet(viewsets.ReadOnlyModelViewSet):
    queryset = Farmer.objects.all()
    serializer_class = FarmerSerializer
    filter_fields = ('town',)

Add filter on the town field on the Farmer model
Add filter on the town field on the Farmer model
