Closed MrFlick closed 1 year ago
Hello,
Or is there an easy way to convert those
neo4j.time.Date
objects into strings in the cypher query itself?
I just did as suggested and it worked. Thank you for your insight!
Part of the Cypher query was rewritten, like this:
actors: [ (a)-[r:ACTED_IN]->(m) | a { .*, born: toString(a.born), died: toString(a.died), role: r.role } ],
As well as for directors.
The webpage displays correctly for me now.
This is probably the easiest suggestion. The more complicated route would be to do this manually in the transaction function write a python function that detects datetime types and calls str()
on them.
It would be nice if the course had fixed queries or official suggestions on how to deal with this kind of transformations. At the moment the code crashes.
When working on the "Project Backlog" section, specifically the "Movie Details" task, I get an error when running the solution provided in the
12-movie-details
branch. When you go to a page likehttp://localhost:3000/movies/9772
. An error will appear in the flask logThe ultimate error "TypeError: Object of type Date is not JSON serializable" seems to be coming from the "born" property of the Actor nodes which are returned to python as objects like
neo4j.time.Date(1986, 10, 14)
and those are not properly serialized by theflask.jsonify
function. The full cypher query used for that task isIs there a recommended work around? Does the code in api/routes/movies.py need to change to so as to not use
jsonify
? Or is there an easy way to convert thoseneo4j.time.Date
objects into strings in the cypher query itself?This occurs running Python 3.9.12 with Flask 2.0.2 and neo4j 4.4.0 using the sample Recommendations graph database.