'I keep getting this error in my code. Why does this keep happening? type object 'RefreshToken' has no attribute 'for_user'

i am trying to create a login view using django rest framework simplejwt and i am using this function to create tokens

from rest_framework_simplejwt.tokens import RefreshToken

def get_tokens_for_user(user):
    refresh = RefreshToken.for_user(user)

    return {
        'refresh': str(refresh),
        'access': str(refresh.access_token),
    }

however /i keep getting this error

     type object 'RefreshToken' has no attribute 'for_user'


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source