From d4b9b1798432d7aeeecb5eb8b0c7cdb432a676c8 Mon Sep 17 00:00:00 2001 From: logaritmisk Date: Thu, 31 Mar 2016 11:34:43 +0200 Subject: [PATCH] Check if related model has int as pk for ManyToMany fields instead if current model. --- reversion_compare/compare.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/reversion_compare/compare.py b/reversion_compare/compare.py index c63b3af..4bd8288 100644 --- a/reversion_compare/compare.py +++ b/reversion_compare/compare.py @@ -137,12 +137,13 @@ def get_many_to_many(self): elif self.value is DOES_NOT_EXIST: return ([], [], [], []) # TODO: refactory that + related_model = self.field.rel.to + ids = None - if self.has_int_pk: + if reversion_api.has_int_pk(related_model): ids = [int(v) for v in self.value] # is: version.field_dict[field.name] # Get the related model of the current field: - related_model = self.field.rel.to return self.get_many_to_something(ids, related_model) def get_many_to_something(self, ids, related_model, is_reverse=False):