Debian Codegraph @

docs/08_permissions.rst

raw
1 .. _permissions-label:
2
3 Permissions
4 ===========
5
6 Django REST Framework allows setting certain ``permission_classes`` in order to control access to views.
7 The generic ``HaystackGenericAPIView`` defaults to ``rest_framework.permissions.AllowAny`` which enforce no
8 restrictions on the views. This can be overridden on a per-view basis as you would normally do in a regular
9 `REST Framework APIView <http://www.django-rest-framework.org/api-guide/permissions/#setting-the-permission-policy>`_.
10
11
12 .. note::
13
14 Since we have no Django model or queryset, the following permission classes are *not* supported:
15
16 - ``rest_framework.permissions.DjangoModelPermissions``
17 - ``rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly``
18 - ``rest_framework.permissions.DjangoObjectPermissions``
19
20 ``POST``, ``PUT``, ``PATCH`` and ``DELETE`` are not supported since Haystack Views
21 are read-only. So if you are using the ``rest_framework.permissions.IsAuthenticatedOrReadOnly``
22 , this will act just as the ``AllowAny`` permission.
23
24
25 **Example overriding permission classes**
26
27 .. code-block:: python
28
29 ...
30 from rest_framework.permissions import IsAuthenticated
31
32 class SearchViewSet(HaystackViewSet):
33 ...
34 permission_classes = [IsAuthenticated]