Browse Source

change category assign

ilya_shyian 1 year ago
parent
commit
27d0f5aa5c
1 changed files with 3 additions and 3 deletions
  1. 3 3
      store_back/apps/categories/schema.py

+ 3 - 3
store_back/apps/categories/schema.py

@@ -140,10 +140,10 @@ class CategoryUpsert(graphene.Mutation):
                 print(category.get("parent",None) == "null")
                 print(category.get("parent",None))
 
-                if category.get("parent",None) == "null":
+                if not category.get("parent")["_id"] == "null":
                     new_category.parent = None
-                    
-                new_category.parent = Category.objects.get(_id=category.get("parent",None)["_id"])
+                else: 
+                    new_category.parent = Category.objects.get(_id=category.get("parent")["_id"])
             except:
                 raise Exception("Невірні дані (parent)")