Skip to content

Commit

Permalink
[-] Set decendent_ids to empty list if not saved
Browse files Browse the repository at this point in the history
  • Loading branch information
coordt committed Oct 13, 2017
1 parent fc6a73d commit 22c5630
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion categories/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,11 @@ def clean(self):

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."))
Expand Down

0 comments on commit 22c5630

Please sign in to comment.