def post(self, *args, **kwargs): ret = {"status": False, "summary": "", "detail": ""} form = JdProductForm() try: is_valid = form.valid(self) if is_valid: merchant_id = 6 print("data", form._value_dict) service = ProductService(ProductRepository()) service.create_product(merchant_id, form._value_dict) ret["status"] = True else: ret["detail"] = form._error_dict except Exception as e: ret["summary"] = str(e) self.write(json.dumps(ret))
def post(self, *args, **kwargs): ret = {'status': False, 'summary': '', 'detail': ""} form = JdProductForm() try: is_valid = form.valid(self) if is_valid: # print(is_valid, form._error_dict, form._value_dict) merchant_id = 14 service = ProductService(ProductRepository()) service.create_product(merchant_id, form._value_dict) ret['status'] = True else: ret['detail'] = form._error_dict except Exception as e: ret['summary'] = str(e) self.write(json.dumps(ret))