本文整理汇总了Python中api.models.User.last_token_spotify方法的典型用法代码示例。如果您正苦于以下问题:Python User.last_token_spotify方法的具体用法?Python User.last_token_spotify怎么用?Python User.last_token_spotify使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类api.models.User
的用法示例。
在下文中一共展示了User.last_token_spotify方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: login
# 需要导入模块: from api.models import User [as 别名]
# 或者: from api.models.User import last_token_spotify [as 别名]
def login(request):
try:
received_json_data = json.loads(request.body)
u = User(spotify_id=received_json_data['spotifyId'])
u.account_type = received_json_data['account_type']
u.user_name = received_json_data["username"]
u.email = received_json_data["email"]
except ValueError:
return HttpResponse("Inavlid Json", status=403)
if u.last_token_spotify != received_json_data["spotifyToken"]:
u.last_token_spotify = received_json_data["spotifyToken"]
if u.check_token_spotify():
u.save()
serializer = AccountSerializer(u, many=False)
return JSONResponse(serializer.data)
return HttpResponse("Spotify user not valid", status=400)