sitetree/admin.py
def save_model(self, request, obj, form, change):
        """Saves TreeItem model under certain Tree.
        Handles item's parent assignment exception.

        """
        if change:
            # No, you're not allowed to make item parent of itself
            if obj.parent is not None and obj.parent.id == obj.id:
                obj.parent = self.previous_parent
                messages.warning(
                    request, _("Item's parent left unchanged. Item couldn't be parent to itself."), '', True)
        obj.tree = self.tree
        obj.save()
def save_model(self, request, obj, form, change):
        if change:
            # No, you're not allowed to make item parent of itself
            if obj.parent is not None and obj.parent.id == obj.id:
                obj.parent = self.previous_parent
                messages.warning(
                    request, _("Item's parent left unchanged. Item couldn't be parent to itself."), '', True)
        obj.tree = self.tree
        obj.save()
def save_model ( self , request , obj , form , change ) : if change : # No, you're not allowed to make item parent of itself if obj . parent is not None and obj . parent . id == obj . id : obj . parent = self . previous_parent messages . warning ( request , _ ( "Item's parent left unchanged. Item couldn't be parent to itself." ) , '' , True ) obj . tree = self . tree obj . save ( )
Saves TreeItem model under certain Tree.
        Handles item's parent assignment exception.
Saves TreeItem model under certain Tree . Handles item s parent assignment exception .