瀏覽代碼

change category assign

ilya_shyian 1 年之前
父節點
當前提交
3a52874d85
共有 1 個文件被更改,包括 7 次插入0 次删除
  1. 7 0
      store_back/apps/categories/schema.py

+ 7 - 0
store_back/apps/categories/schema.py

@@ -132,6 +132,13 @@ class CategoryUpsert(graphene.Mutation):
         except Exception as e:
 
             new_category = Category(**category)
+            
+        
+        if "parent" in category:
+            try:
+                new_category.parent = Category.objects.get(_id=category.get("parent",None)["_id"])
+            except:
+                raise Exception("Невірні дані (parent)")
 
         new_category.save()
         if len(good_list):