mirror of
https://github.com/jazzband/django-categories.git
synced 2026-03-16 22:30:24 +00:00
[-] Set decendent_ids to empty list if not saved
This commit is contained in:
parent
fc6a73d8e5
commit
22c5630af2
1 changed files with 5 additions and 1 deletions
|
|
@ -111,7 +111,11 @@ class CategoryBaseAdminForm(forms.ModelForm):
|
|||
|
||||
if self.cleaned_data.get('parent', None) is None or self.instance.id is None:
|
||||
return self.cleaned_data
|
||||
decendant_ids = self.instance.get_descendants().values_list('id', flat=True)
|
||||
if self.instance.pk:
|
||||
decendant_ids = self.instance.get_descendants().values_list('id', flat=True)
|
||||
else:
|
||||
decendant_ids = []
|
||||
|
||||
if self.cleaned_data['parent'].id == self.instance.id:
|
||||
raise forms.ValidationError(_("You can't set the parent of the "
|
||||
"item to itself."))
|
||||
|
|
|
|||
Loading…
Reference in a new issue