Open khamitovdr opened 1 year ago
tortoise-orm==0.19.3
class FileBaseModel(models.Model): host = fields.ForeignKeyField( "models.Equipment", related_name="files", on_delete=fields.CASCADE, null=True ) @pre_delete(FileBaseModel) async def equipment_media_pre_delete( sender: Type[FileBaseModel], file: FileBaseModel, using_db: Optional[BaseDBAsyncClient], ) -> None: log.info(f"pre_delete signal for file {file}")
equipment = await Equipment.create(...) file = await FileBaseModel.create(host=equipment) await file.delete() #### INFO: pre_delete signal for file <FileBaseModel> file = await FileBaseModel.create(host=equipment) await equipment.delete() #### Nothing happens! No logs...
@denis240997 I think this is the expected behavior. The pre_delete signal is registered on FileBaseModel, not on Equipment.
pre_delete
FileBaseModel
Equipment
tortoise-orm==0.19.3
Setup
Code