django permission on api

This commit is contained in:
sinavir 2023-02-16 19:09:40 +01:00
parent 4e77270a93
commit f03c371255

View file

@ -1,5 +1,5 @@
from rest_framework import viewsets from rest_framework import viewsets
from rest_framework.permissions import IsAuthenticatedOrReadOnly from rest_framework.permissions import DjangoModelPermissionsOrAnonReadOnly
from .models import BudgetGroup, BudgetLine from .models import BudgetGroup, BudgetLine
from .serializers import BudgetGroupSerializer, BudgetLineSerializer from .serializers import BudgetGroupSerializer, BudgetLineSerializer
@ -8,10 +8,10 @@ from .serializers import BudgetGroupSerializer, BudgetLineSerializer
class BudgetGroupViewSet(viewsets.ModelViewSet): class BudgetGroupViewSet(viewsets.ModelViewSet):
queryset = BudgetGroup.objects.all() queryset = BudgetGroup.objects.all()
serializer_class = BudgetGroupSerializer serializer_class = BudgetGroupSerializer
permission_class = [IsAuthenticatedOrReadOnly] permission_class = [DjangoModelPermissionsOrAnonReadOnly]
class BudgetLineViewSet(viewsets.ModelViewSet): class BudgetLineViewSet(viewsets.ModelViewSet):
queryset = BudgetLine.objects.all() queryset = BudgetLine.objects.all()
serializer_class = BudgetLineSerializer serializer_class = BudgetLineSerializer
permission_class = [IsAuthenticatedOrReadOnly] permission_class = [DjangoModelPermissionsOrAnonReadOnly]