Hello,
I’ve also encountered this error and the solution of @CarlosDC is working but the behavior is different from the previous version of the guide. This causes also an issue with finding the correct DB entries to delete, because the ID’s are not the “same” anymore.
When I’m using the exact code from the guide I also get the error: “pydantic.errors.PydanticUserError: The __modify_schema__ method is not supported in Pydantic v2. Use __get_pydantic_json_schema__ instead.”
When I try the suggested solution on stackoverflow I’ve noticed that the _id attribute is no longer a string but it’s stored as an ObjectId('6501....'). When I try to use the ID as a string it no longer finds the DB entry.
This breaks the old way it was used and renders the guide incorrect.
Any suggestions how to fix this to get the old behavior?
Thanks in advance!