Tortoise-orm pydantic_model_creator, how to add no-database/abstract properties to a model?

33 views Asked by At

I'm using fastapi and Tortoise ORM, I need add an no-database property to a model like this:

class Account(models.Model):
    id = fields.IntField(pk=True)
    email = fields.CharField(max_length=64)
    is_new = 0 # this is the abstract property will be set other value in service.

Account_Pydantic = pydantic_model_creator(Account, name="Account")

but this will not have property is_new in the schema, and when I generate open-api dart codes, it will come errors. Can anyone helps? Thanks a lot.

0

There are 0 answers