【发布时间】:2021-04-22 12:17:00
【问题描述】:
我有一个名为 branch 的模型,在保存我正在使用的分支时:
with transaction.atomic():
#previous processing
obj.save()
#additional codes
我创建 post_save 信号如下:
@receiver(signals.post_save, sender=Branch)
def update_reporter_header(sender, instance,created, **kwargs):
""" When Add or Edit a Branch The related data to branch must be change
Args:
sender ([Branch]): [the model Who kept under eye when any change]
instance ([Branch]): [description]
created ([boolean]): [return true if instance created else False]
"""
if created:
她是否需要交易
for obj in HeaderFooter.bobjects.all().filter(branch_id=instance.id,customize=False,is_appeare=True):
obj.data = getattr(instance,obj.name)
obj.save()
【问题讨论】:
标签: transactions django-signals