[Fixed]-How can i use the base django base permissions to limited user access?


Since it appears that you’re using django-rest-framework, I recommend you look at the documentation on permissions for django-rest-framework. Specifically, the section you will want is DjangoModelPermissions.

An example of how you would implement this (assuming a class based view) would look like:

from rest_framework.permissions import DjangoModelPermissions
from rest_framework.views import APIView

from .models import MyModel

class MyView(APIView):
    permission_classes = (DjangoModelPermissions,)
    queryset = MyModel.objects.all()

Keep in mind that, as stated in the documentation, you must provide a queryset attribute on the view class in order for this to work.

Leave a comment