

def db_value(self, value):
    if isinstance(value, self.rel_model):
        value = value._get_pk_value()
    return self.to_field.db_value(value)

dataset/ETHPy150Open coleifer/peewee/peewee.py ForeignKeyField.db_value/original