HeroBase, HeroCreate, HeroUpdate, Hero, HeroUPdate, HeroPublic
These uppers are some classes for my hero related thigns,
@app.post("/heroes/", response_model=HeroPublic)
def create_hero(hero: HeroCreate, session: SessionDep):
# some code of working with db
db_hero:Hero # this Hero class is database class contains all info
return db_heroFrom this function i return a Hero class obj, but response_model = HeroPublic so it means even i return the Hero class the fastapi actually sending the HeroPUblic to the end user upon this request fastpi received.
right so i am confused why we not actually do return HeroPUblic.Model_validate(db_hero) without need to write response_model,
why the docs say to use the response_model alwasy there, why not like the upper model_validate!!!
pls i am very not getting this, as this is the problem i am not able to fully understand and integrate sqlmodel with my flask app, pls help me i have this problem still now, what i will do now with this.
as i will use flask, that there is no response model in flask as u said