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',)

from rest_framework import viewsets, permissions

from .models import Farmer
from .serializers import FarmerSerializer


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

Add permission settings on FarmerViewSet
Add permission settings on FarmerViewSet
