Skip to content

Commit 48dde42

Browse files
committed
fix: handle situations with no prev parent
1 parent aef7a7e commit 48dde42

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

polymorphic_tree/admin/parentadmin.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,13 @@ def api_node_moved_view(self, request):
189189

190190
position = request.POST['position']
191191

192-
if isinstance(moved_id, integer_types) and isinstance(target_id, integer_types):
193-
previous_parent_id = int(request.POST['previous_parent_id']) or None
192+
if request.POST.get('previous_parent_id'):
193+
if isinstance(moved_id, integer_types) and isinstance(target_id, integer_types):
194+
previous_parent_id = int(request.POST['previous_parent_id'])
195+
else:
196+
previous_parent_id = request.POST['previous_parent_id']
194197
else:
195-
previous_parent_id = request.POST['previous_parent_id'] or None
198+
previous_parent_id = None
196199

197200
# Not using .non_polymorphic() so all models are downcasted to the derived model.
198201
# This causes the signal below to be emitted from the proper class as well.

0 commit comments

Comments
 (0)