I am using diff_against in simple_history in django.
See "history diffing" in simple_history docs:
https://django-simple-history.readthedocs.io/en/latest/history_diffing.html
I have this all working, but it states:
"diff_against also accepts 2 arguments excluded_fields and included_fields to either explicitly include or exclude fields from being diffed."
I can't figure out how to pass these fields. Here is what I have that is working (without any include or exclude fields):
def historical_changes(qry, id):
changes = []
if qry is not None and id:
last = qry.first()
for all_changes in range(qry.count()):
new_record, old_record = last, last.prev_record
if old_record is not None:
delta = new_record.diff_against(old_record)
changes.append(delta)
last = old_record
return changes
and I call it in a detail view using:
changes = historical_changes(hpn.history.all(), hpn.pk)
This all works. I then tried to incldue the "exclude_field". These are what I tried, but none worked:
delta = new_record.diff_against(old_record, excluded_fields('geom'))
or
delta = new_record.diff_against(old_record).excluded_fields('geom')
or
delta = new_record.diff_against(old_record.excluded_fields('geom'))
This is likley something quite simple, but I'm not figuring it out. Any help would be great. Thanks.
You should use it like so:
delta = new_record.diff_against(old_record, excluded_fields=['geom'])
diff_against
accepts a keyword argument excluded_fields
rather than excluded_fields
being a method of an HistoricalRecords
class.