def newproduct(request): product_name = request.data['product'] category_id = request.data['category'] sub_catagory_id=request.data['subcategory'] productService_obj = productService() result = productService_obj.addProduct(product_name,category_id,sub_catagory_id) dataobj = {'data': result} return HttpResponse(json.dumps(dataobj, cls=DjangoJSONEncoder), content_type='application/json', status=200)
def getAllProducts(request): productService_obj = productService() result = productService_obj.listAllProducts() dataobj = {'data': result} return HttpResponse(json.dumps(dataobj, cls=DjangoJSONEncoder), content_type='application/json', status=200)
def getProductSubCategory(request): sub_catagory_id=request.GET['id'] productService_obj = productService() result = productService_obj.listProductsSubcategoty(sub_catagory_id) dataobj = {'data': result} return HttpResponse(json.dumps(dataobj, cls=DjangoJSONEncoder), content_type='application/json', status=200)