Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Check if new parent is not a descendant of current category
Marcin Gębala66b49f913513
diff --git a/saleor/dashboard/category/forms.py b/saleor/dashboard/category/forms.pyindex 56e24181f1..522f5b0865 100644--- a/saleor/dashboard/category/forms.py+++ b/saleor/dashboard/category/forms.py@@ -18,4 +18,6 @@ class CategoryForm(forms.ModelForm):parent = self.cleaned_data['parent']if parent == self.instance:raise forms.ValidationError(_('A category may not be made a child of itself'))+ if self.instance in parent.get_ancestors():+ raise forms.ValidationError(_('A category may not be made a child of any of its descendants.'))return parent