From c0ff616761d1f21083df3e3798beb257d0f01357 Mon Sep 17 00:00:00 2001 From: Carl van Tonder Date: Sat, 19 May 2018 14:32:57 -0400 Subject: [PATCH] Prevent crash saving case study with no draft --- apps/map/views.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/map/views.py b/apps/map/views.py index 0f5741d..764fd7f 100644 --- a/apps/map/views.py +++ b/apps/map/views.py @@ -79,9 +79,11 @@ class BaseForm(LoginRequiredMixin, CreateView): self.send_email() # Delete the corresponding draft - draft = CaseStudyDraft.objects.get(author=self.request.user) - if draft: + try: + draft = CaseStudyDraft.objects.get(author=self.request.user) draft.delete() + except CaseStudyDraft.DoesNotExist: + pass return super().form_valid(form)