From 24db787f6840e33a285580491a698bdf898fd0bb Mon Sep 17 00:00:00 2001 From: Paul Eggleton Date: Tue, 20 Mar 2018 16:34:25 +1300 Subject: [PATCH] rrs/models: handle All missing in milestones If we call objects.get() with no matching record then the result will be an exception, not a null return, so handle that properly. Signed-off-by: Paul Eggleton --- rrs/models.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rrs/models.py b/rrs/models.py index 35dcc40..c7d8ea0 100644 --- a/rrs/models.py +++ b/rrs/models.py @@ -14,6 +14,7 @@ from datetime import date from django.db import models from django.contrib.auth.models import User from layerindex.models import Recipe, LayerBranch +from django.core.exceptions import ObjectDoesNotExist class MaintenancePlan(models.Model): @@ -78,7 +79,10 @@ class Milestone(models.Model): milestones = [] today = date.today() - mall = Milestone.objects.get(release__plan=maintplan, release__name=release_name, name='All') + try: + mall = Milestone.objects.get(release__plan=maintplan, release__name=release_name, name='All') + except ObjectDoesNotExist: + mall = None if mall: milestones.append(mall)