You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When creating a post and there's no user logged in, the result shows "Authentication credentials were not provided", something like that.
When I'm trying to create a post and there's no user logged in, it doesn't show the message above. It still proceed in creating.
When creating a post and there's no user logged in, the result shows "Authentication credentials were not provided", something like that.
When I'm trying to create a post and there's no user logged in, it doesn't show the message above. It still proceed in creating.
What do I need to do?
This the code the I used.
from rest_framework.generics import (
CreateAPIView,
DestroyAPIView,
ListAPIView,
UpdateAPIView,
RetrieveAPIView,
RetrieveUpdateAPIView
)
from rest_framework.permissions import (
AllowAny,
IsAuthenticated,
IsAdminUser,
IsAuthenticatedOrReadOnly,
from posts.models import Post
from .permissions import IsOwnerOrReadOnly
from .serializers import (
PostCreateUpdateSerializer,
PostDetailSerializer,
PostListSerializer
)
class PostCreateAPIView(CreateAPIView):
queryset = Post.objects.all()
serializer_class = PostCreateUpdateSerializer
permission_classes = [IsAuthenticated]
class PostDetailAPIView(RetrieveAPIView):
queryset = Post.objects.all()
serializer_class = PostDetailSerializer
lookup_field = 'slug'
#lookup_url_kwarg = "abc"
class PostUpdateAPIView(RetrieveUpdateAPIView):
queryset = Post.objects.all()
serializer_class = PostCreateUpdateSerializer
lookup_field = 'slug'
permission_classes = [IsAuthenticatedOrReadOnly, IsOwnerOrReadOnly]
#lookup_url_kwarg = "abc"
def perform_update(self, serializer):
serializer.save(user=self.request.user)
#email send_email
class PostDeleteAPIView(DestroyAPIView):
queryset = Post.objects.all()
serializer_class = PostDetailSerializer
lookup_field = 'slug'
#lookup_url_kwarg = "abc"
class PostListAPIView(ListAPIView):
queryset = Post.objects.all()
serializer_class = PostListSerializer
The text was updated successfully, but these errors were encountered: