[Django]-I am getting this error rest_framework.request.WrappedAttributeError

9👍

IsAuthenticated is a Permission Class not an Authentication class. So it should be as


class AccountInfoUpdate(APIView):
    permission_classes = [IsAuthenticated]
    # your code

UPDATE-1
How to resolve CSRF Failed error

1. Open a new tab in POSTMAN
POSTMAN Screenshot
2. Provide URL(1)
3. Go to Authorization tab(2) and setect Basic Auth then provide your username and password
4. Then go to Body tab, and enter your JSON payload.
5. Hit send button. There you go

👤JPG

1👍

I was also getting this error "rest_framework.request.WrappedAttributeError: ‘IsAuthenticated’ object has no attribute ‘authenticate’" error in following manner:

my login code was having:

def post(self, request,):
        username = request.data.get("username")
        password = request.data.get("password")
        user = authenticate(username=username, password=password)

While i was getting error, REST_FRAMEWORK contained following in settings.py:

REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': (
        'rest_framework.authentication.TokenAuthentication',
        'rest_framework.authentication.SessionAuthentication',
    ),  
}

Later i added following also and my error was gone:

REST_FRAMEWORK = {
    ......
    'DEFAULT_PERMISSION_CLASSES': (
        'rest_framework.permissions.IsAuthenticated',
    )   
}

You can try and give feedback please.

0👍

"CSRF Failed: CSRF token missing or incorrect." problem is solved by front end site but still its not working in postman side. Anyway, my problem is solved frond-end side by this link after long RND.

Leave a comment