

def create_relationship(self, from_obj, to_obj, name, inverse_name=None, computed=False):
    from_ct = ContentType.objects.get_for_model(from_obj)
    to_ct = ContentType.objects.get_for_model(to_obj)
    (reltype, is_new) = RelationshipType.objects.get_or_create(from_type=from_ct, to_type=to_ct, name=name, inverse_name=inverse_name, computed=computed)
    (rel, is_new) = self.get_or_create(type=reltype, from_content_type=from_ct, from_object_id=from_obj.pk, to_content_type=to_ct, to_object_id=to_obj.pk, computed=computed)
    return rel

dataset/ETHPy150Open wq/wq.db/patterns/relate/models.py RelationshipManager.create_relationship/original