From f0b517709a324dfe32c8f9af7c1631cbf85d51cb Mon Sep 17 00:00:00 2001 From: Zaytsev Dmitry Date: Wed, 30 Aug 2017 13:35:12 +0300 Subject: [PATCH] fixed error with data comments key --- instagram/models.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/instagram/models.py b/instagram/models.py index d2517ca2..47ae6817 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 entry['comments'].get('data'): + 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'):