tortoise-orm
tortoise-orm copied to clipboard
use only for nested model fields
Hi There!
How to make only for nested model fields
Example:
class A:
id = fields.IntField()
name = fields.CharField()
other_field = fields.CharField()
class B:
id = fields.IntField()
b_name = fields.CharField()
a = fields.ForeignKeyField('models.A', related_name='Bs', on_delete=fields.CASCADE)
B.all().select_related('a').only('id', 'b_name', 'a__name')
This example will throw
KeyError: 'a__name'
Current you can use .values
@long2ice this won't help if you want to use pydantic schemas :(
i need it too.
This feature could be useful in our project.