Skip to content

Custom authentication & permissions

By default the viewsets use DjangoModelPermissionsOrAnonReadOnly permissions class from DRF.

This can be altered in the DRF settings by adapting DEFAULT_PERMISSION_CLASSES.

You can also add custom permissions when registering their corresponding viewsets, as permission_classes. Example in models.py:

from rest_framework import permissions
from django.contrib.gis.db import models
from django_oapif import register_oapif_viewset

@register_oapif_viewset(
    custom_viewset_attrs={
        "permission_classes": (permissions.DjangoModelPermissionsOrAnonReadOnly,)
    }
)
class MyModel(models.Model):
    ...