Adding permissions to views
DRF includes a permission system to restrict access to views. Some of the built-in permissions of DRF are:
AllowAny: Unrestricted access, regardless of whether a user is authenticated or not.IsAuthenticated: Allows access to authenticated users only.IsAuthenticatedOrReadOnly: Complete access to authenticated users. Anonymous users are only allowed to execute read methods such asGET,HEAD, orOPTIONS.DjangoModelPermissions: Permissions tied todjango.contrib.auth. The view requires aquerysetattribute. Only authenticated users with model permissions assigned are granted permission.DjangoObjectPermissions: Django permissions on a per-object basis.
If users are denied permission, they will usually get one of the following HTTP error codes:
HTTP 401: UnauthorizedHTTP 403: Permission denied
You can read more information about permissions at https://www.django-rest-framework.org/api...