Django Rest Framework - read only views


Django REST Framework tip:

You can use ReadOnlyModeViewSet when you don't want to allow any unsafe operations (POST, DELETE, PATCH).

An example👇

class BlogViewSet(ReadOnlyModeViewSet):
    """
    A simple ViewSet for viewing blogs.
    """

    queryset = Blog.objects.all()
    serializer_class = BlogSerializer