Promptly-Technologies-LLC / fastapi-jinja2-postgres-webapp

A template webapp with a pure-Python FastAPI backend, frontend templating with Jinja2, and a Postgres database to power user auth
https://promptlytechnologies.com/fastapi-jinja2-postgres-webapp/
MIT License
0 stars 0 forks source link

Create a reusable `as_form` helper function that can be mounted as a method on Pydantic request models #34

Closed chriscarrollsmith closed 1 week ago

chriscarrollsmith commented 1 week ago

I've made a few failed attempts at this, but I think the key may be to mount the method after the class is initialized rather than to do it during class initialization, which is what I previously tried.

chriscarrollsmith commented 1 week ago

As best I can tell, mypy isn't going to let us do this. It doesn't like the dynamic setting of attributes. And the code quickly gets quite complicated and uninterpretable when you try it anyway.