Field not in the DB #200
-
Hey everyone, I was wondering if this project supports defining columns at runtime as class Table(Base):
id: int
name: str and I would like to show a column in the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
you can create a custom field and override the parse_obj function. Example: class MyCustomField(BooleanField):
async def parse_obj(self, request: Request, obj: Any) -> Any:
return 'active' in obj.name then you can define your field list like this: fields = ['id', 'name', MyCustomField('status', exclude_from_create=True, exclude_from_edit=True)] Full example -> https://github.com/jowilf/starlette-admin-demo/blob/ad82fde9acf7dbd5a2cf58d51ec2e3db61451ba6/app/sqla/fields.py#L24 For more information -> https://jowilf.github.io/starlette-admin/advanced/custom-field/ |
Beta Was this translation helpful? Give feedback.
you can create a custom field and override the parse_obj function.
Example:
then you can define your field list like this:
Full example -> https://github.com/jowilf/starlette-admin-demo/blob/ad82fde9acf7dbd5a2cf58d51ec2e3db61451ba6/app/sqla/fields.py#L24
For more information -> https://jowilf.github.io/starlette-admin/advanced/custom-field/