Browse Source

datetime object not JSON serializable

Fixed error where a datetime object cannot be stored in request.sessions
as it was not JSON serializable.
master
Chris 7 years ago
parent
commit
588fc4bfc0
  1. 2
      spotifyvis/views.py

2
spotifyvis/views.py

@ -77,7 +77,7 @@ def callback(request):
response = requests.post('https://accounts.spotify.com/api/token', data = payload).json() response = requests.post('https://accounts.spotify.com/api/token', data = payload).json()
# despite its name, datetime.today() returns a datetime object, not a date object # despite its name, datetime.today() returns a datetime object, not a date object
request.session['token_obtained_at'] = datetime.datetime.today()
request.session['token_obtained_at'] = str(datetime.datetime.today())
request.session['access_token'] = response['access_token'] request.session['access_token'] = response['access_token']
request.session['refresh_token'] = response['refresh_token'] request.session['refresh_token'] = response['refresh_token']
request.session['valid_for'] = response['expires_in'] request.session['valid_for'] = response['expires_in']

Loading…
Cancel
Save