piccolo-orm / piccolo

A fast, user friendly ORM and query builder which supports asyncio.
https://piccolo-orm.com/
MIT License
1.45k stars 91 forks source link

Feature request: support for dynamic choices #524

Open scott2b opened 2 years ago

scott2b commented 2 years ago

Since choices takes an enum rather than a callable, it is not clear how one would provide choices dynamically. It would be ideal if we could provide dynamic choices so that, for example, the choices themselves could be stored in a table.

cheesycod commented 2 years ago

Hmmm... how does Django and other ORMs handle this

dantownsend commented 2 years ago

We could let the user pass in a function.

It does introduce some challenges though. For example, we have to make sure Piccolo Admin keeps refetching the table schema just in case the choices have changed.

Also, would the function return a list of potential values, or an Enum.

cheesycod commented 2 years ago

maybe a dict of key: value's