From be264a4b03ad026b067b9fe0c2844dfb78ac4ec1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?An=C3=ADbal=20Lim=C3=B3n?= Date: Tue, 17 Feb 2015 13:11:05 +0000 Subject: [PATCH] rrs/models.py: RecipeMaintainerHistory if not found return the first record MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Aníbal Limón --- rrs/models.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rrs/models.py b/rrs/models.py index 64d7985..d24bf92 100644 --- a/rrs/models.py +++ b/rrs/models.py @@ -153,6 +153,11 @@ class RecipeMaintainerHistory(models.Model): rmh_qry = RecipeMaintainerHistory.objects.filter( date__lte = end_date).order_by('-date') + if rmh_qry: + return rmh_qry[0] + + rmh_qry = RecipeMaintainerHistory.objects.filter( + ).order_by('date') if rmh_qry: return rmh_qry[0] else: