A while ago, I allowed myself to be persuaded into adding an added/changed/deleted flag to the Version model, which has proven to be the worst idea ever, and is scheduled for removal in an upcoming release.
So its best to ignore that aspect of django-reversion.
The way it's supposed to work, and will continue to work forever, is analogous to Git scm, in that a Revision consists of a consistent snapshot of a group of related models (or just one model). If you delete a model, then django-reversion knows that it's been deleted because its PK is in the version table, but not in the "live" table. There is no record for "x has been deleted" (well, there is, but that was the "worst idea ever" feature mentioned above, and it will be removed very soon).
So, finding out who deleted a model is tricky. Your solution 1 is a good approach, and will continue to work for future releases of django-reversion. So use that!
--
You received this message because you are subscribed to the Google Groups "django-reversion discussion group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-reversi...@googlegroups.com.
To post to this group, send an email to django-r...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-reversion.
For more options, visit https://groups.google.com/groups/opt_out.
There is no record for "x has been deleted" (well, there is, but that was the "worst idea ever" feature mentioned above, and it will be removed very soon).
1. When deleting the object, first call save() and set a comment to say the object was deleted. Then call delete.
with reversion.revision():
obj.save()
reversion.set_comment("Deleted by user")
obj.delete()
It's a valid use-case, I realise.
The thin to remember about django-reversion is that it's about point-in-time recovery, which is different to an undo feature.
With an undo feature, you would find the "action" that caused the deletions, and undo it.
With point-in-time recovery, you would recover the model from a time where it wasn't deleted.
In its purest form, django-reversion wouldn't store comments or user models associated with a revision at all. This was only done to make the admin integration much simpler.
With a typical version control system, you'd snapshot the entire state of the project in the form of a diff, or a complete snapshot, at which point a deletion is represented as a negative diff for the contents of a file.
When version controlling data in a database, snapshotting the entire database for each revision isn't feasible for anything other than toy databases. If you treat each table as a standalone entity, then recording deletions becomes possible.
However, when a revision contains a group of models from different tables, the situation becomes vastly more complicated. At this point a revision can be sent to represent the state of a collection of related models at a point in time. If a snapshot is saved again at a later date, then you can tell if a model has been deleted because it will be absent from the later revision.
In your case, I would listen to the delete signal for your models, and log these deletions against the initiating user. Then in the event of a large-scale deletion, you can look at what was deleted, and recover it.
In this way, you separate the "audit trail" and "snapshotting/recovery" features into two separate concerns, which is probably how django-reversion should have been written in the first place.
--
In its purest form, django-reversion wouldn't store comments or user models associated with a revision at all. This was only done to make the admin integration much simpler.
In your case, I would listen to the delete signal for your models, and log these deletions against the initiating user. Then in the event of a large-scale deletion, you can look at what was deleted, and recover it.
In this way, you separate the "audit trail" and "snapshotting/recovery" features into two separate concerns, which is probably how django-reversion should have been written in the first place.
It's a valid use-case, I realise.
The thin to remember about django-reversion is that it's about point-in-time recovery, which is different to an undo feature.
--
Simply put, some projects don't use django.contrib.auth. By making the user field part of the Revision model, it's required to install django.contrib.auth even if it's never going to be used in your project.django-reversion has a more generic way of attaching meta information to a revision. In retrospect, using that would have been a good decision. However, it's most likely too late to make that sort of change now!
Would using contenttype break that strong dependence?
Although I have a hard time understanding a use for reversions without contrib.auth. If you don't use contrib.auth, how do you control who has permission to revert revisions?An anonymous only wiki perhaps? But that would still need an administrator I would imagine.
--
how to get deleted list of some model. Table id is serial pk and never have more than one version of same model and i need to get list of all deleted objects and user, date of objects are deleted i tried this deleted_list = reversion.get_deleted (Model) and in this dont get user and date when are deleted excusme my english :( Trato de escribir lo mejor que puedo
--
You received this message because you are subscribed to the Google Groups "django-reversion discussion group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-reversi...@googlegroups.com.
To post to this group, send email to django-r...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-reversion.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "django-reversion discussion group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-reversion/SB953FlKoSc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-reversi...@googlegroups.com.