def create_token(user):
jwt_payload_handler = api_settings.JWT_PAYLOAD_HANDLER
jwt_encode_handler = api_settings.JWT_ENCODE_HANDLER
payload = jwt_payload_handler(user)
token = jwt_encode_handler(payload)
return token
user_obj = User.objects.create(username=username, password=password2, phone=phone)
token = create_token(user_obj)
data = {
"username": user_obj.username,
"phone": user_obj.phone,
"token": token
}