IsAdminUser permission is not allowing staff users

76 views
Skip to first unread message

Siddid Soni

unread,
Aug 16, 2024, 4:33:27 PM8/16/24
to Django REST framework
IsAdminUser permission is not allowing staff users to access the endpoint 

@api_view(['POST'])
@permission_classes([IsAdminUser])
def approve(request):
    booking_id = request.data['booking_id']
    booking_instance = booking.objects.get(id=booking_id)
    booking_instance.status = 'a'
    booking_instance.save()

    return Response({'message': 'Booking approved'})

api response for superuser
{
  "detail": "You do not have permission to perform this action."
}

pls help

Viktor Yaremenko

unread,
Oct 12, 2024, 10:35:46 AM10/12/24
to Django REST framework
Hello

With these improvements, your API should now correctly handle booking approvals, providing helpful feedback on errors and ensuring that only authorized users can approve bookings. If you continue to experience issues, please verify the user’s admin status and check your authentication setup.

Reply all
Reply to author
Forward
0 new messages