批量保存过程,post_save没有运行?

时间:2013-08-24 17:58:59

标签: python django django-models

我正在运行批处理保存过程,但是我的post_save函数似乎没有针对每个对象运行?任何人都可以阻止任何问题吗?

保存功能

 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

@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)

1 个答案:

答案 0 :(得分:1)

除了post_savebulk_create之外,

update不会被解雇。