Browse Source

change category assign

ilya_shyian 1 year ago
parent
commit
3a52874d85
1 changed files with 7 additions and 0 deletions
  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):