def save(self, obj, data):
        if not self.readonly:
            value = data.get(self.column_name)
            current = set(self.widget.clean(value))
            # filter old assignments to obj by through_model
            old_objs = set([
                getattr(i, self.through_to_field_name) for i in
                self.through_model.objects.filter(
                    **{self.through_from_field_name: obj}
                ).select_related(
                    self.through_to_field_name
                )
            ])

            to_add = old_objs - current
            to_remove = old_objs - current

            to_add_list = []
            for i in to_add:
                logger.info('Adding {} to {}/{} assignments'.format(
                    i.pk, self.through_model, obj.pk
                ))
                to_add_list.append(self.through_model(
                    **{
                        self.through_from_field_name: obj,
                        self.through_to_field_name: i
                    }
                ))

            if to_add_list:
                self.through_model.objects.bulk_create(to_add_list)
            if to_remove:
                logger.warning('Removing assignments from {}/{}: {}'.format(
                    self.through_model, obj.pk, [i.pk for i in to_remove]
                ))
                self.through_model.objects.filter(
                    **{
                        self.through_from_field_name: obj,
                        '{}__in'.format(self.through_to_field_name): to_remove
                    }
                ).delete()
dataset/ETHPy150Open allegro/ralph/src/ralph/data_importer/fields.py/ThroughField.save/swapped operands of `-`