def update_ancestor(sender, instance, **kwargs):
if kwargs['created'] or not kwargs['update_fields'] or 'parent' in kwargs['update_fields']:
ancestor_or_self = instance.recursive_ancestor_or_self()
if instance.ancestor_or_self != ancestor_or_self:
FundingInstitution.objects.filter(id=instance.id).update(
ancestor_or_self=ancestor_or_self
)
if not kwargs['raw']:
for child in instance.fundinginstitution_set.all():
post_save.send(
sender=sender,
instance=child,
raw=kwargs['raw'],
created=kwargs['created'],
using=kwargs['using'],
update_fields=kwargs['update_fields'],
)
评论列表
文章目录