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

Documentation doesn't cover how to progamatically compare versions #107

Open
ptav opened this issue Aug 5, 2018 · 3 comments
Open

Documentation doesn't cover how to progamatically compare versions #107

ptav opened this issue Aug 5, 2018 · 3 comments

Comments

@ptav
Copy link

ptav commented Aug 5, 2018

The current documentation explains how to integrate with Django admin but doesn't cover the use case where two versions need to be compared inside the code (e.g. producing a report of changes). thank you

@rrauenza
Copy link

@ptav Did you have any success doing this? I'm trying to figure out how to integrate this into a REST interface ... but the docs seem to be very View or Admin specific.

@rrauenza
Copy link

rrauenza commented Jan 17, 2019

Here's what I have gotten so far:

In [8]: from reversion_compare.mixins import CompareMixin

In [10]: CompareMixin().compare(Version.objects.all()[0].object, Version.objects.all()[0], rm.Version.objects.all()[1])

Out[10]: 
([{'diff': u'<span>2018-08-28 17:10:</span><del style="background:#ffe6e6;">40.928</del><ins style="background:#e6ffe6;">02.932</ins><span>000+00:00</span>',
   'field': <django.db.models.fields.DateTimeField: last_login>,
   'follow': None,
   'is_related': False}],
 True)

@jedie
Copy link
Owner

jedie commented Jan 18, 2019

but the docs seem to be very View or Admin specific

The original goal was only the admin site ;)

I think the best thing to do is look here:

Think it makes sense to move the "main" code from mixins.py to a better place, where it's useable in other situations, too (e.g.: REST-API sterilizer...)

Pull requests are welcome ;)

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

No branches or pull requests

3 participants