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

- from rest_framework import viewsets
+ from rest_framework import viewsets, permissions
  
  from .models import Farmer
  from .serializers import FarmerSerializer
  
  
- class FarmerViewSet(viewsets.ReadOnlyModelViewSet):
+ class FarmerViewSet(viewsets.ModelViewSet):
      queryset = Farmer.objects.all()
      serializer_class = FarmerSerializer
      filter_fields = ('town',)
+     permissions = permissions.DjangoModelPermissionsOrAnonReadOnly
  
Add permission settings on FarmerViewSet
## Code Before:
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',)

## Instruction:
Add permission settings on FarmerViewSet
## Code After:
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
