From ef8e1d9e84e84cf9162d9ddef88e64ad61d7db32 Mon Sep 17 00:00:00 2001 From: amaney Date: Wed, 8 Jun 2016 11:11:58 +0300 Subject: [PATCH] Update models.py This will fix KeyError on `entry['comments']['data']` when using a sandboxed app --- 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'):