From 2100b19574c519277a744d6bd81d473f81e0d0b0 Mon Sep 17 00:00:00 2001 From: Jordan Hyatt Date: Mon, 16 Sep 2024 19:53:30 -0400 Subject: [PATCH] removed call to field cache --- simple_history/models.py | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/simple_history/models.py b/simple_history/models.py index c028ca49..80ecdde6 100644 --- a/simple_history/models.py +++ b/simple_history/models.py @@ -954,25 +954,20 @@ class HistoricReverseOneToOneDescriptor(ReverseOneToOneDescriptor): def get_queryset(self, **hints): instance = hints.get("instance") if instance: - try: - return instance._prefetched_objects_cache[ - self.related.field.remote_field.get_cache_name() - ] - except (AttributeError, KeyError): - history = getattr(instance, SIMPLE_HISTORY_REVERSE_ATTR_NAME, None) - histmgr = getattr( - self.related.related_model, - getattr( - self.related.related_model._meta, - "simple_history_manager_attribute", - "_notthere", - ), - None, + history = getattr(instance, SIMPLE_HISTORY_REVERSE_ATTR_NAME, None) + histmgr = getattr( + self.related.related_model, + getattr( + self.related.related_model._meta, + "simple_history_manager_attribute", + "_notthere", + ), + None, + ) + if history and histmgr: + return histmgr.as_of( + getattr(history, "_as_of", history.history_date) ) - if history and histmgr: - return histmgr.as_of( - getattr(history, "_as_of", history.history_date) - ) return super().get_queryset(**hints)