[英]batch save process, post_save not running?
I'm running a batch save process, however my post_save function does not seem to be running for each object? 我正在运行批处理保存过程,但是我的post_save函数似乎没有为每个对象运行? Can anyone stop any issues? 谁能阻止任何问题?
save function 保存功能
objs = [
Message(
recipient_number=e.mobile,
content=content,
sender=e.contact_owner,
billee=user,
sender_name=sender,
gateway=gateway,
)
for e in query
]
# Send messages to DB
Message.objects.bulk_create(objs)
models.py models.py
@receiver(post_save, sender=Message)
def my_post_save_handler(sender, instance, **kwargs):
"""
Post Save Signal.
Sent at the end of the save() method. Attached to 'Message'.
"""
print("=========================================")
print(instance.gateway)
instance.send(instance.gateway)
post_save.connect(my_post_save_handler, sender=Message)
post_save
不会因为bulk_create
和update
而被触发。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.