def get_intermediate_model_to_field(self, klass):
        name = self.get_intermediate_model_name(klass)

        to_model, to_object_name = self.get_rel_to_model_and_object_name(klass)

        if self.rel.to == RECURSIVE_RELATIONSHIP_CONSTANT or to_object_name == klass._meta.object_name:
            field_name = 'to_%s' % to_object_name.lower()
        else:
            field_name = to_object_name.lower()

        field = models.ForeignKey(to_model, related_name='%s+' % name,
                                  **get_foreignkey_field_kwargs(self))
        return field_name, field
dataset/ETHPy150Open gregmuellegger/django-sortedm2m/sortedm2m/fields.py/SortedManyToManyField.get_intermediate_model_to_field/original