-
-
Notifications
You must be signed in to change notification settings - Fork 483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extend source model's QuerySet manager to Historical model? #963
Comments
@tim-schilling it looks like a reasonable approach to the same problem. Only thing I forget is needing (in some cases a lot of) duplicated code to bring the queryset classes over from the live one (but that might be unavoidable). Excited to see something like this! |
@dwasyl Ah, I think I covered that in the docs: class QuestionQuerySet(HistoricalQuerySet):
def question_prefixed(self):
return self.filter(question__startswith='Question: ')
class HistoryQuestionQuerySet(QuestionQuerySet, HistoricalQuerySet):
"""Redefine QuerySet with base class HistoricalQuerySet"""
class Question(models.Model):
pub_date = models.DateTimeField('date published')
history = HistoricalRecords(historical_queryset=HistoryQuestionQuerySet)
manager = models.Manager.from_queryset(QuestionQuerySet)() |
That's what I get for giving it only a quick look! I wasn't familiar with the |
Getting ahead of myself on this great unreleased feature, but..
Based on the great work added in #866, is it at all possible to extend the object manager from the source model to the
Historical
model? The idea here is that now thatas_of()
returns aHistoricalQuerySet
most of the filtering I want to do on the historical models is based on filtering I would do on live objects.Since a custom
ModelManager
orQuerySetManager
that provides chainable filters would work on historical models, to avoid repeating them again, is there a way to use the same manager on theHistoricalModel
?The text was updated successfully, but these errors were encountered: