Browse Source

change category assign

ilya_shyian 1 năm trước cách đây
mục cha
commit
3a52874d85
1 tập tin đã thay đổi với 7 bổ sung0 xóa
  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):