Skip to content

Commit

Permalink
removed call to field cache
Browse files Browse the repository at this point in the history
  • Loading branch information
JordanHyatt committed Sep 16, 2024
1 parent 8f3c94e commit 2100b19
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions simple_history/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down

0 comments on commit 2100b19

Please sign in to comment.