diff --git a/spotifyvis/migrations/0002_auto_20180608_2002.py b/spotifyvis/migrations/0002_auto_20180608_2002.py new file mode 100644 index 0000000..b7e48e7 --- /dev/null +++ b/spotifyvis/migrations/0002_auto_20180608_2002.py @@ -0,0 +1,18 @@ +# Generated by Django 2.0.5 on 2018-06-09 00:02 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('spotifyvis', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='artist', + name='genre', + field=models.CharField(max_length=30), + ), + ] diff --git a/spotifyvis/migrations/0003_auto_20180608_2007.py b/spotifyvis/migrations/0003_auto_20180608_2007.py new file mode 100644 index 0000000..323ca26 --- /dev/null +++ b/spotifyvis/migrations/0003_auto_20180608_2007.py @@ -0,0 +1,18 @@ +# Generated by Django 2.0.5 on 2018-06-09 00:07 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('spotifyvis', '0002_auto_20180608_2002'), + ] + + operations = [ + migrations.AlterField( + model_name='track', + name='name', + field=models.CharField(max_length=150), + ), + ] diff --git a/spotifyvis/models.py b/spotifyvis/models.py index f09c87a..07f73ff 100644 --- a/spotifyvis/models.py +++ b/spotifyvis/models.py @@ -13,7 +13,7 @@ class Artist(models.Model): artist_id = models.CharField(primary_key=True, max_length=MAX_ID) # unique since only storing one genre per artist right now name = models.CharField(unique=True, max_length=50) - genre = models.CharField(max_length=20) + genre = models.CharField(max_length=30) def __str__(self): return self.name @@ -49,7 +49,7 @@ class Track(models.Model): year = models.PositiveSmallIntegerField() popularity = models.PositiveSmallIntegerField() runtime = models.PositiveSmallIntegerField() - name = models.CharField(max_length=75) + name = models.CharField(max_length=150) users = models.ManyToManyField(User, blank=True) def __str__(self): diff --git a/spotifyvis/utils.py b/spotifyvis/utils.py index b23b3c0..40d116d 100644 --- a/spotifyvis/utils.py +++ b/spotifyvis/utils.py @@ -90,6 +90,7 @@ def save_track_obj(track_dict, artists, user): :returns: (The created/retrieved Track object, created) """ + print(track_dict['name']) new_track, created = Track.objects.get_or_create( track_id=track_dict['id'], year=track_dict['album']['release_date'].split('-')[0], @@ -308,7 +309,7 @@ def update_artist_genre(headers, artist_obj): :returns: None """ - artist_response = requests.get('https://api.spotify.com/v1/artists/' + artist_obj.id, headers=headers).json() + artist_response = requests.get('https://api.spotify.com/v1/artists/' + artist_obj.artist_id, headers=headers).json() # update genre for artist in database with top genre artist_obj.genre = artist_response['genres'][0] artist_obj.save()