Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Redirect to the original root after updating category

Marcin Gębalad10417f07add
diff --git a/saleor/dashboard/category/views.py b/saleor/dashboard/category/views.py
index 767e479311..4f0f28697d 100644
--- a/saleor/dashboard/category/views.py
+++ b/saleor/dashboard/category/views.py
@@ -42,16 +42,16 @@ def category_create(request, root_pk=None):
@staff_member_required
def category_edit(request, pk=None):
category = get_object_or_404(Category, pk=pk)
+ root = category.parent
title = category.name
form = CategoryForm(request.POST or None,
instance=category,
- initial={'parent': category.parent})
+ initial={'parent': root})
if form.is_valid():
category = form.save()
messages.success(request, _('Updated category %s') % category)
- if category.parent:
- return redirect('dashboard:category-list',
- root_pk=category.parent.pk)
+ if root:
+ return redirect('dashboard:category-list', root_pk=root.pk)
else:
return redirect('dashboard:category-list')
elif form.errors: