From 5e6ff4e76f2dff3d69aa4330f5b8fdb86a740d21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=AD=C3=B0ir=20Valberg=20Gu=C3=B0mundsson?= Date: Sun, 15 Apr 2018 19:44:14 +0200 Subject: [PATCH] Fix #179. --- src/program/consumers.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/program/consumers.py b/src/program/consumers.py index d5ac9dc8..741144e7 100644 --- a/src/program/consumers.py +++ b/src/program/consumers.py @@ -83,13 +83,19 @@ class ScheduleConsumer(JsonWebsocketConsumer): ) if action == 'unfavorite': - event_instance_id = content.get('event_instance_id') - event_instance = EventInstance.objects.get(id=event_instance_id) - favorite = Favorite.objects.get( - event_instance=event_instance, - user=user - ) - favorite.delete() + try: + event_instance_id = content.get('event_instance_id') + event_instance = EventInstance.objects.get( + id=event_instance_id + ) + favorite = Favorite.objects.get( + event_instance=event_instance, + user=user + ) + favorite.delete() + except EventInstance.DoesNotExist: + # We don't want to do anything. + return if data: self.send_json(data)