Skip to content

Commit

Permalink
Explicitly get queryset when using query methods
Browse files Browse the repository at this point in the history
  • Loading branch information
macro1 committed Oct 31, 2014
1 parent c5ed822 commit 242cfb4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions simple_history/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def most_recent(self):
tmp.append(field.name)
fields = tuple(tmp)
try:
values = self.values_list(*fields)[0]
values = self.get_queryset().values_list(*fields)[0]
except IndexError:
raise self.instance.DoesNotExist("%s has no historical record." %
self.instance._meta.object_name)
Expand All @@ -68,7 +68,7 @@ def as_of(self, date):
"""
if not self.instance:
return self._as_of_set(date)
queryset = self.filter(history_date__lte=date)
queryset = self.get_queryset().filter(history_date__lte=date)
try:
history_obj = queryset[0]
except IndexError:
Expand All @@ -84,7 +84,7 @@ def as_of(self, date):
def _as_of_set(self, date):
model = type(self.model().instance) # a bit of a hack to get the model
pk_attr = model._meta.pk.name
queryset = self.filter(history_date__lte=date)
queryset = self.get_queryset().filter(history_date__lte=date)
for original_pk in set(
queryset.order_by().values_list(pk_attr, flat=True)):
changes = queryset.filter(**{pk_attr: original_pk})
Expand Down

0 comments on commit 242cfb4

Please sign in to comment.