Dissociate previously associated model from the given parent.

        :rtype: eloquent.Model
482397
def dissociate(self):
        
        self._parent.set_attribute(self._foreign_key, None)

        return self._parent.set_relation(self._relation, None)
1312708
protected function updateActiveParents(array $parents)
    {
        $modelInfo       = $this->getModelInformation();
        $modelClass      = $modelInfo->modelClass();
        $model           = new $modelClass;
        $previousContext = null;
        $previousParent  = array_shift($parents);
        $separator       = $this->getListParentSeparator();

        // Store top level parent as active
        if ( ! $previousParent || is_string($previousParent) && false === strpos($previousParent, $separator)) {
            $this->listParentRelation  = $previousParent === false ? false : null;
            $this->listParentRecordKey = null;
        } else {
            list($this->listParentRelation, $this->listParentRecordKey) = explode($separator, $previousParent, 2);
        }

        $count = 0;

        // Add 'end' marker to force overwriting a previously longer chain link as a terminator
        $parents[] = null;

        // Loop through further parents, where $parent is what $previousParent refers back to
        foreach ($parents as $parent) {

            $count++;

            // If we have no interpretable parent to use as sub-context, stop
            if ( ! $previousParent || is_string($previousParent) && false === strpos($previousParent, $separator)) {
                break;
            }

            // If we have no interpretable parent as target, clear the context, and stop
            if ( ! $parent || is_string($parent) && false === strpos($parent, $separator)) {
                $this->setListParentDataInMemory(null, null, $previousParent, $previousContext);
                break;
            }

            list($relation, $key) = explode($separator, $parent, 2);

            // Set new parent at this level
            $this->setListParentDataInMemory($relation, $key, $previousParent, $previousContext);

            // If this is the last parent, then there is no need to prepare for the next iteration
            if ($count == count($parents)) {
                break;
            }

            // If the context (model) changed, determine the new context and remember it for the next iteration
            $listParentInfo = $this->getListParentInformation($model, $relation, $key, $modelInfo);

            if ( ! count($listParentInfo)) {
                break;
            }

            // Check and update the model class (for the memory context) if necessary.
            // This is only relevant for list parent reference across models.
            $listParentInfo = head($listParentInfo);
            /** @var ListParentData $listParentInfo */

            if ($modelClass !== get_class($listParentInfo->model)) {
                $model           = $listParentInfo->model;
                $modelClass      = get_class($model);
                $previousContext = $this->getModelSessionKey($this->getModuleHelper()->modelSlug($model));
            }

            $previousParent = $parent;
        }
    }
1275491
def associate(self, model):
        
        self._parent.set_attribute(self._foreign_key, model.get_key())
        self._parent.set_attribute(self._morph_type, model.get_morph_name())

        return self._parent.set_relation(
            self._relation, Result(model, self, self._parent)
        )
147563
public function removeAll()
    {
        foreach ($this->_associated_objects as $parent_property => $object) {
            /**
             * @var Model
             */
            $object->setDirty($parent_property);
        }
        $this->exchangeArray([]);
    }
904539
public function dissociate()
    {
        $morphKey  = $this->morphKey;
        $morphType = $this->morphType;

        $this->parent->setAttr($morphKey, null);
        $this->parent->setAttr($morphType, null);
        $this->parent->save();

        return $this->parent->setRelation($this->relation, null);
    }
492102
function() {
			Backbone.Relational.store.getCollection( this.instance )
				.unbind( 'relational:remove', this._modelRemovedFromCollection );
			
			Backbone.Relational.store.getCollection( this.relatedModel )
				.unbind( 'relational:add', this._relatedModelAdded )
				.unbind( 'relational:remove', this._relatedModelRemoved );
			
			_.each( this.getReverseRelations(), function( relation ) {
					relation.removeRelated( this.instance );
				}, this );
		}
3681
def remove_core_element(self, model):
        
        assert model.transition.parent is self.model.state or model.transition.parent is self.model.parent.state
        gui_helper_state_machine.delete_core_element_of_model(model)
190376
def change_parent(sender, instance, **kwargs):
    
    if instance.id is None:
        return
    if len({'term', 'term_id'} & set(instance.changed_fields)) != 0:
        diff = instance.diff
        parent = diff['term'][0] if 'term' in diff else diff['term_id'][0]
        child_id = instance.item_id
        if parent is not None:
            parent_id = parent.item_id if isinstance(parent, Term) else Term.objects.get(pk=parent).item_id
            ItemRelation.objects.filter(parent_id=parent_id, child_id=child_id).delete()
        ItemRelation.objects.get_or_create(parent_id=instance.term.item_id, child_id=child_id, visible=True)
    if len({'term_secondary', 'term_secondary_id'} & set(instance.changed_fields)) != 0:
        diff = instance.diff
        child_id = instance.item_id
        parent = diff['term_secondary'][0] if 'term_secondary' in diff else diff['term_secondary_id'][0]
        if parent is not None:
            parent_id = parent.item_id if isinstance(parent, Term) else Term.objects.get(pk=parent).item_id
            ItemRelation.objects.filter(parent_id=parent_id, child_id=child_id).delete()
        if instance.term_secondary is not None or instance.term_secondary_id is not None:
            ItemRelation.objects.get_or_create(parent_id=instance.term_secondary.item_id, child_id=child_id, visible=True)
    if len({'context', 'context_id'} & set(instance.changed_fields)) != 0:
        diff = instance.diff
        parent = diff['context'][0] if 'context' in diff else diff['context_id'][0]
        child_id = instance.item_id
        if parent is not None:
            parent_id = parent.item_id if isinstance(parent, Context) else Context.objects.get(pk=parent).item_id
            ItemRelation.objects.filter(parent_id=parent_id, child_id=child_id).delete()
        ItemRelation.objects.get_or_create(parent_id=instance.context.item_id, child_id=child_id, visible=True)
266721
def remove_instance(self):
        
        with fields.FieldLock(self.related_field):
            related_pks = self()
            for pk in related_pks:

                # get the real related field
                related_instance = self.related_field._model(pk)
                related_field = getattr(related_instance, self.related_field.name)

                # check if we have a dedicated remove method
                remover = getattr(related_field, '_related_remover', None)

                # then remove the instance from the related field
                if remover is not None:
                    # if we have a remover method, it wants the instance as argument
                    # (the related field may be a set/list/sorted_set)
                    getattr(related_field, remover)(self.instance._pk)
                else:
                    # no remover method, simple delete the field
                    related_field.delete()
271413
public function dissociate()
    {
        $this->child->setAttribute($this->foreignKey, null);

        return $this->child->setRelation($this->relation, null);
    }
114328
def remove_from_parent(self):
        """"""
        parent = self.parent
        if parent is not None:
            try:
                children = parent.children
            except AttributeError: pass
            else:
                remove_upto_once(children, self)
455674
def remove(self, parent):
        
        if parent not in self._aggregates:
            raise ValueError("Sensor %r does not have an aggregate rule "
                             "associated" % parent)
        children = self.children(parent)
        try:
            self.remove_links(parent, children)
        except Exception:
            pass
        del self._aggregates[parent]
1284261
function beforeRemoveMany_(attr, event, callback) {
    try {
        if (event.state !== 4) { return callback(); }
        var context = event.model.context,
            name = attr.property || attr.name;
        var nestedModel = context.model(attr.type);
        if (_.isNil(nestedModel)) { return callback(); }
        //get junction
        var junction = event.target.property(name);
        //select object identifiers (get all objects in silent mode to avoid orphaned objects)
        junction.select(nestedModel.getPrimaryKey()).silent().all().then(function(result) {
            //first of all remove all associations
            junction.clear(function(err) {
                if (err) { return callback(err); }
                //and afterwards remove nested objects
                nestedModel.silent().remove(result, function(err) {
                    if (err) { return callback(); }
                });
            });
        }).catch(function(err) {
           return callback(err);
        });
    }
    catch (err) {
        callback(err)
    }
}
132748
function (parent) {
            var options = this.__opts || {};
            var ds, self = this;
            if (!isUndefined((ds = options.dataset)) && isFunction(ds)) {
                ds = ds.apply(parent, [parent]);
            }
            if (!ds) {
                var q = {};
                this._setAssociationKeys(parent, q);
                ds = this.model.dataset.naked().filter(q);
                var recip = this.model._findAssociation(this);
                recip && (recip = recip[1]);
                ds.rowCb = function (item) {
                    var model = self._toModel(item, true);
                    recip && recip.__setValue(model, parent);
                    //call hook to finish other model associations
                    return model._hook("post", "load").chain(function () {
                        return model;
                    });
                };
            } else if (!ds.rowCb && this.model) {
                ds.rowCb = function (item) {
                    var model = self._toModel(item, true);
                    //call hook to finish other model associations
                    return model._hook("post", "load").chain(function () {
                        return model;
                    });
                };
            }

            return this._setDatasetOptions(ds);
        }
852296
function destroyRelation(model, relations) {
  if (!model) {
    throw new Error('No model provided.');
  }
  return _destructure2['default'](model, relations).then(function (destructured) {
    var relations = destructured.relations;
    return _transact2['default'](model, function (transaction) {
      return _relate2['default'](model, relations, 'delete', transaction);
    });
  });
}
112045
def base_definition_pre_delete(sender, instance, **kwargs):
    
    # see CASCADE_MARK_ORIGIN's docstring
    cascade_deletion_origin = popattr(
        instance._state, '_cascade_deletion_origin', None
    )
    if cascade_deletion_origin == 'model_def':
        return
    if (instance.base and issubclass(instance.base, models.Model) and
            instance.base._meta.abstract):
        instance._state._deletion = instance.model_def.model_class().render_state()
576257
def detachChildren(self):
        
        detached = self.children
        self.children = []
        for child in detached:
            child.parent = None
        return detached