I am trying to pass in some more data to the jwt token authentication, i have written a Serialize for this and passed in some other fields like full_name, image, pin etc now i am trying to pass in the wallet field which is a DecimalField
in my Model, then i am getting this error. Object of type Decimal is not JSON serializable
how do i fix this?
token['wallet'] = user.profile.wallet
Complete Serializer
class MyTokenObtainPairSerializer(TokenObtainPairSerializer):
@classmethod
def get_token(cls, user):
token = super().get_token(user)
# Add custom claims
token['username'] = user.username
token['email'] = user.email
token['full_name'] = user.profile.full_name
token['bio'] = user.profile.bio
token['country'] = user.profile.country
token['image'] = user.profile.image.url
token['address'] = user.profile.address
token['phone'] = user.profile.phone
token['website'] = user.profile.website
token['pin'] = user.profile.pin
token['verified'] = user.profile.verified
token['wallet'] = user.profile.wallet
return token
Do i need to convert the wallet field to a decimal field first?