Django Signal Not Triggering After Bulk Create with Custom Manager
I am trying to implement a `post_save` signal in my Django application that should trigger after a bulk create operation using a custom manager. However, I'm finding that the signal doesn't get fired when I use the `bulk_create()` method. Here's a simplified version of my code: ```python from django.db import models from django.db.models.signals import post_save from django.dispatch import receiver class MyModel(models.Model): name = models.CharField(max_length=100) @classmethod def bulk_create_custom(cls, objs, **kwargs): return cls.objects.bulk_create(objs, **kwargs) @receiver(post_save, sender=MyModel) def my_model_post_save(sender, instance, created, **kwargs): if created: print(f'New instance created: {instance.name}') # Usage docs = [MyModel(name='doc1'), MyModel(name='doc2')] MyModel.bulk_create_custom(docs) ``` When I run this code, I expect to see the print statement in the `my_model_post_save` function, but nothing happens. I’ve confirmed that the `bulk_create()` method is executing and the records are indeed being created in the database. I read that `bulk_create()` does not call `save()` on individual instances, which is likely why the signal is not being triggered. I tried to call `save()` method on each instance manually after the bulk create, but that seems inefficient since this defeats the purpose of using `bulk_create()` for performance. Is there a recommended approach to trigger signals after a bulk create operation, or do I need to rethink my design? Any insights would be really helpful!