def edit_stock(request, pk): data = json.loads(request.data) stock = data.get("stock") if stock is None: raise BadRequest("Stock is required") Sale = Sale.update(stock=stock).where(Sale.id == pk).execute() return 200, json.dumps(model_to_dict(Sale.select().where(Sale.id == pk).get()))
def update_stock(stock, pk): Sale = Sale.update(stock=stock).where(Sale.id == pk).execute() print("Stock updated") return 200