Skip to content

bulk_create() does NOT send signals #332

@YassouSr

Description

@YassouSr

I am using bulk_create() function to insert multiple records, however all changes made by this function are not logged correctly with CRUD event :

            with transaction.atomic():  # Ensures atomicity
                created = Inscription.objects.bulk_create(valid_inscriptions)

            # throw save signal for log easyaudit
            # since bulk_create bypass post_save signal
            for inst in created:
                post_save.send(sender=Inscription, instance=inst, created=True, raw=False)

I have tried the above solution to call signal but it throws error : TypeError: post_save() missing 2 required positional arguments: 'using' and 'update_fields'

I also searched that it is not a good idea to call save signal manually, and also due to large data I cannot loop through data and save records one by one due to optimization problems and response time.

Any other solution would be appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions