Lena
Lena

Reputation: 1

Python(flask) PUT TypeError: Todo.put() got multiple values for argument 'todo_id'

REACT + PYTHON

I am creating todo list app using react and python. But update todo function is not working properly and gave meTypeError: Todo.put() got multiple values for argument 'todo_id'

    @blp.arguments(TodoUpdateSchema)
    @blp.response(200, TodoSchema)
    def put(self, todo_id, todo_data):

        todo = TodoModel.query.get(todo_id)
        if todo:
            todo.todo = todo_data["todo"]
            todo.checked = todo_data["checked"]
        else:
            return {"message": "todo not found"}

        db.session.add(todo)
        db.session.commit()

        return todo 

this is my python handling method and from react i am sending

export const updateTodo = async (id: number, editTodo: EditTodo) => {
  const response = await axios.put(`${TODO_API_URL}/${id}`, editTodo);
  return response.data;
};

and it gave me 422 method. I have no idea how to fix it. Can anyone help me please?

class TodoSchema(Schema):
    id = fields.Int(dump_only=True)
    date = fields.Date(required=True)
    todo = fields.Str(required=True)
    checked = fields.Bool(required=False)


class TodoUpdateSchema(Schema):
    class Meta:
        unknown = EXCLUDE

    todo = fields.Str(required=True)
    checked = fields.Bool(required=True)

I kept changing the schema and parameter to send ..but nothing working

Upvotes: 0

Views: 25

Answers (0)

Related Questions