Skip to content

Commit

Permalink
Handle Django 5.1 deprecation for get_cache_name
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-schilling committed Nov 20, 2024
1 parent baef016 commit 4af5154
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions simple_history/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -901,9 +901,13 @@ def related_manager_cls(self):
class HistoricRelationModelManager(related_model._default_manager.__class__):
def get_queryset(self):
try:
return self.instance._prefetched_objects_cache[
# DEV: Remove this when support for Django 4.2 has been dropped
cache_name = (
self.field.remote_field.get_cache_name()
]
if django.VERSION < (5, 0)
else self.field.remote_field.cache_name
)
return self.instance._prefetched_objects_cache[cache_name]
except (AttributeError, KeyError):
history = getattr(
self.instance, SIMPLE_HISTORY_REVERSE_ATTR_NAME, None
Expand Down

0 comments on commit 4af5154

Please sign in to comment.