From 9eefe811f6b7ff75cc2312963370b650678eff13 Mon Sep 17 00:00:00 2001 From: LopsanAMO Date: Wed, 12 Jul 2017 19:43:12 -0500 Subject: [PATCH] adding a empty list if not data in request comment --- instagram/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/instagram/models.py b/instagram/models.py index d2517ca2..8404341e 100644 --- a/instagram/models.py +++ b/instagram/models.py @@ -96,7 +96,7 @@ def object_from_dictionary(cls, entry): new_media.comment_count = entry['comments']['count'] new_media.comments = [] - for comment in entry['comments']['data']: + for comment in entry['comments'].get('data', []): new_media.comments.append(Comment.object_from_dictionary(comment)) new_media.users_in_photo = [] @@ -112,7 +112,7 @@ def object_from_dictionary(cls, entry): new_media.caption = None if entry['caption']: new_media.caption = Comment.object_from_dictionary(entry['caption']) - + new_media.tags = [] if entry['tags']: for tag in entry['tags']: