From b43d4dc77f7834c7dbfc1589a3b7ff5af1c52638 Mon Sep 17 00:00:00 2001 From: Jean-Romain Garnier Date: Fri, 24 Apr 2020 18:15:34 +0000 Subject: [PATCH] Fix bugs introduced while improving performance --- logs/models.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/logs/models.py b/logs/models.py index 49404690..f5796f93 100644 --- a/logs/models.py +++ b/logs/models.py @@ -449,15 +449,13 @@ class VersionAction(HistoryEvent): serialized_data__icontains='"pk": {}'.format(self.object_id()) ) & Q( - revision__date_created_lt=self.version.revision.date_created + revision__date_created__lt=self.version.revision.date_created ) ) - return next( - Version.objects.get_for_model(model) + return (Version.objects.get_for_model(model) .filter(query) - .order_by("-revision__date_created") - ) - except StopIteration: + .order_by("-revision__date_created")[0]) + except Exception as e: return None def _compute_diff(self, v1, v2, ignoring=["pwd_ntlm"]):