code: def clean_parent(self):
          
          data = self.cleaned_data['parent']
          if data == self.instance:
              raise forms.ValidationError(
                  _('A category cannot be parent of itself.'),
                  code='self_parenting')
          return data
docs: Check if category parent is not selfish.