From 0636de01d24f3ddf54d0889634adbdf76e2c7e0d Mon Sep 17 00:00:00 2001 From: Keaton Law Date: Thu, 27 Feb 2025 19:04:57 -0600 Subject: [PATCH] added authentication class to viewset --- api/views/post.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/api/views/post.py b/api/views/post.py index 8298d42e..ec4fa0cf 100644 --- a/api/views/post.py +++ b/api/views/post.py @@ -2,7 +2,7 @@ from django.core.paginator import Paginator from django.contrib.auth.models import User from django.contrib.contenttypes.models import ContentType -from rest_framework import response, serializers, status, viewsets +from rest_framework import response, serializers, status, viewsets, permissions class AuthorSerializer(serializers.ModelSerializer): class Meta: @@ -25,6 +25,8 @@ def get_like_count(self, obj): return Like.objects.filter(content_type=content_type, object_id=obj.id).count() class PostViewSet(viewsets.ViewSet): + permission_classes = [permissions.IsAuthenticated] + def list(self, request): page_number = request.GET.get("page") posts = Post.objects.all().order_by("created_at").reverse()