From aa1301e1d83abba2d3c9edaeb43095724fd9a081 Mon Sep 17 00:00:00 2001 From: marianovolarik Date: Sun, 18 Dec 2016 10:21:28 -0300 Subject: [PATCH] KeyError: 'data' fixed. --- instagram/models.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/instagram/models.py b/instagram/models.py index d2517ca2..90a53065 100644 --- a/instagram/models.py +++ b/instagram/models.py @@ -96,8 +96,9 @@ def object_from_dictionary(cls, entry): new_media.comment_count = entry['comments']['count'] new_media.comments = [] - for comment in entry['comments']['data']: - new_media.comments.append(Comment.object_from_dictionary(comment)) + if "data" in entry["comments"]: + for comment in entry['comments']['data']: + new_media.comments.append(Comment.object_from_dictionary(comment)) new_media.users_in_photo = [] if entry.get('users_in_photo'):