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
Check if category parent is not selfish.
dataset/ETHPy150Open Fantomas42/django-blog-zinnia/zinnia/admin/forms.py/CategoryAdminForm.clean_parent