Skip to content
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

Get previous revision delta in template? #797

Open
brylie opened this issue Feb 19, 2021 · 2 comments · May be fixed by #798
Open

Get previous revision delta in template? #797

brylie opened this issue Feb 19, 2021 · 2 comments · May be fixed by #798

Comments

@brylie
Copy link
Member

brylie commented Feb 19, 2021

Problem Statement
When iterating over a revision history in a Django template, there doesn't appear to be a method to get the delta between revisions.

Describe the solution you'd like
From any revision, I would like to get the difference of that revision and the previous revision, while iterating over the revisions in a Django template.

Describe alternatives you've considered
I've considered writing a custom view that provides history diffing or perhaps extending the History base model with a get_prev_record_diff method.

@brylie
Copy link
Member Author

brylie commented Feb 19, 2021

I have found how the prev_record field is created on history revisions:

def get_prev_record(self):
"""
Get the previous history record for the instance. `None` if first.
"""
history = utils.get_history_manager_for_model(self.instance)
return (
history.filter(Q(history_date__lt=self.history_date))
.order_by("history_date")
.last()
)

I will open a pull request for consideration.

brylie added a commit that referenced this issue Feb 19, 2021
Closes #797

Added next and previous record diffs for consistency
@brylie brylie linked a pull request Feb 19, 2021 that will close this issue
11 tasks
@brylie
Copy link
Member Author

brylie commented Feb 19, 2021

I opened a draft pull request for feedback: #798

brylie added a commit that referenced this issue Oct 26, 2021
Closes #797

Added next and previous record diffs for consistency
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant