rest api error 1

rest api error

Cannot apply DjangoModelPermissionsOrAnonReadOnly on a view that does not set `.queryset` or have a `.get_queryset()` method.

Here is what the above code is Doing:
1. The first line imports the DjangoModelPermissionsOrAnonReadOnly class from the rest_framework.permissions module.
2. The second line creates a permission_classes tuple that contains the DjangoModelPermissionsOrAnonReadOnly class.
3. The third line adds the permission_classes tuple to the viewset.

Now, if you try to access the API endpoint without being authenticated, you’ll get a 403 Forbidden response.

If you want to allow anonymous users to access the API endpoint, you can use the DjangoModelPermissionsOrAnonReadOnly class.

Similar Posts