Skip to content

Commit

Permalink
Use .pk instead of .id when referring to related object.
Browse files Browse the repository at this point in the history
  • Loading branch information
peterlisak committed Jan 4, 2019
1 parent a304297 commit f96f972
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 f96f972

Please sign in to comment.