-
Notifications
You must be signed in to change notification settings - Fork 487
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
"Revert" feature in admin reverts entire revision, not specific version #874
Comments
Looks like this is the same root problem as #798 |
This is an interesting problem. I think it should be possible to introspect the admin class and only revert the specific object. There's a few variations of this approach that might be worth supporting.
I'd be reluctant to change the defaut behaviour, as it could break existing deployments. Adding in the option to enable (2) or (3) on a per-admin basic would make sense though. |
We were recently bit by this issue as well... our use case was as follows:
Our naive understanding is that this wouldn't have happened, if when deleting a model via Django admin a new revision had been created for this model. This way, when restoring the deleted object, this revision created immediately before deletion would have been reverted, and not the last one, which happened to contain edits to many unrelated objects. Could @etianen please explain why no revision is created upon deletion of the objects via Django admin? It seems to me that if this was done, then the use case of @simonw would have been covered as well, and it doesn't have the downsides of the two mentioned alternative approaches, so maybe it can be made to the default behaviour... |
Unfortunately, saving deletions as revisions was removed as a mis-feature a long while ago. See #164 for an in-depth discussion. |
Just got caught out by this one. This button here, on
/admin/app/model/recover/ID/
:Calls this code here:
django-reversion/reversion/admin.py
Lines 164 to 172 in df3bcf7
Note that it's calling
version.revision.revert(delete=True)
here.The problem is,
django-reversion
supports bundling multiple changes to different objects up into a single revision. In our application we use this to bundle up a bunch of bulk-edits made by an API endpoint, using code that looks like this:We used this to update twenty location objects at once. But then... someone clicked the "Save" button to recover an older version of one of those twenty objects, and all twenty were invisibly reverted!
Some potential fixes:
_reversion_revisionform_view
to only affect the specific object, not touching any of the other objects that were bundled into the same revision. That's my preferred fix!The text was updated successfully, but these errors were encountered: