Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add validation on category parent field
Marcin Gębalae1c57cb41c59
diff --git a/saleor/dashboard/category/forms.py b/saleor/dashboard/category/forms.pyindex 528b79fc4b..cd7d9167c8 100644--- a/saleor/dashboard/category/forms.py+++ b/saleor/dashboard/category/forms.py@@ -1,4 +1,5 @@from django import forms+from django.utils.translation import ugettext_lazy as _from ...product.models import Category@@ -6,4 +7,10 @@ from ...product.models import Categoryclass CategoryForm(forms.ModelForm):class Meta:model = Category- exclude = []\ No newline at end of file+ exclude = []++ def clean_parent(self):+ parent = self.cleaned_data['parent']+ if parent == self.instance:+ raise forms.ValidationError(_('A category may not be made a child of itself'))+ return parent