-
-
Notifications
You must be signed in to change notification settings - Fork 445
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Please, provide support for this feature. Currently ModelMeta metaclass ignores source_field for ForeignKey fields (just appends '_id' to field name). I've managed myself to fix this with one-liner directly inside tortoise-orm source code (can't create an abstract subclass of ModelMeta/Model, because Tortoise.init isn't setting _db field to all internal objects of orm), but this does not seem like a reliable fix.
Example where this can be helpful:
class Lambda(Model):
id = fields.IntField(pk=True, null=False)
class Related(Model):
lambda_ = fields.ForeignKeyField(
'models.A',
source_field='lambda' # !
)
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working