Skip to content

Commit

Permalink
Merge pull request #110 from peterlisak/bug-id
Browse files Browse the repository at this point in the history
Use .pk instead of .id when referring to related object.
  • Loading branch information
jedie committed Jan 4, 2019
2 parents a304297 + f96f972 commit bb68825
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions reversion_compare/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def get_reverse_foreign_key(self):
ids = set()
else:
# If there is a _ptr this is a multi-inheritance table and inherits from a non-abstract class
ids = {force_text(v.id) for v in getattr(obj, force_text(self.field.related_name)).all()}
ids = {force_text(v.pk) for v in getattr(obj, force_text(self.field.related_name)).all()}
if not ids and any([f.name.endswith('_ptr') for f in obj._meta.get_fields()]):
# If there is a _ptr this is a multi-inheritance table and inherits from a non-abstract class
# lets try and get the parent items associated entries for this field
Expand All @@ -140,7 +140,7 @@ def get_reverse_foreign_key(self):
else:
p_obj = getattr(p, 'object_version').object
if type(p_obj) != type(obj) and hasattr(p_obj, force_text(self.field.related_name)):
ids = {force_text(v.id) for v in getattr(p_obj, force_text(self.field.related_name)).all()}
ids = {force_text(v.pk) for v in getattr(p_obj, force_text(self.field.related_name)).all()}
else:
return {}, {}, [] # TODO: refactor that

Expand Down

0 comments on commit bb68825

Please sign in to comment.