Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explain how to create revisions with bulk actions #925

Open
dehnert opened this issue Oct 19, 2022 · 1 comment
Open

Explain how to create revisions with bulk actions #925

dehnert opened this issue Oct 19, 2022 · 1 comment

Comments

@dehnert
Copy link

dehnert commented Oct 19, 2022

The documentation notes:

Bulk actions, such as Queryset.update(), do not send signals, so won’t be noticed by django-reversion.

It would be helpful to expand that infobox with how people can work around that if desired and generate the versions anyway. In particular, I think looping over the queryset and using add_to_revision should work. Of course it would be good include a performance caveat, especially if #924 isn't fixed first.

Possible text:

Bulk actions (such as Queryset.update(), Queryset.bulk_update, or Queryset.bulk_create()) do not send signals, so won’t be noticed by django-reversion. You can use add_to_revision with bulk_update or bulk_create as a workaround, but this may eliminate the performance advantage of doing bulk actions since this requires fetching the objects into memory (unlike update()) and reversion will do one query per new version object (#924).

@etianen
Copy link
Owner

etianen commented Oct 29, 2022

I'd take a PR that documented this. Your approach is sound, and the performance would still be better than performing mutiple save()s on the models.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants