Python API development course by Sanjeev Thiagrajan

I have been following Sanjeev’s course from sometime when creating the post using the below path operation has shownby Sanjeev in the course:
@app.post(“/posts”)
def create_posts(post: Post):
post_dict=post.dict()

post_dict['id']= randrange(0,1000000)
my_posts.append(post_dict)
return{"data": post_dict}

it shows that post.dict() has got depreciated and can no longer be used,instead it shows the post.model_dump() to be used to convert it into dict which is not working for me and I am stuck.Can someone please help me out ? Thanks in advance

What is not working exactly? post.model_dump() should give you a dict and you can print it to check.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.