Last active
December 9, 2015 09:51
-
-
Save shishirsharma/bbf35599016df0f8c1e2 to your computer and use it in GitHub Desktop.
A brief history of all objects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A brief history of all objects |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SlotCapacityAdmin(reversion.VersionAdmin): | |
readonly_fields = (slot', 'start_time’, 'end_time’, ‘date’) | |
#... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import reversion | |
@reversion.register | |
class SlotCapacity(models.Model): | |
slot = models.ForeignKey(Slot, null=True, blank=True) | |
# ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
reversions = reversion.get_for_object(self) | |
for reversion in reversions: | |
if reversion.revision.user: | |
name = revers.revision.user.first_name + " " + revers.revision.user.last_name | |
email = revers.revision.user.email | |
serialized_data = json.loads(reversion.serialized_data) | |
reversion_data = {} | |
reversion_data[status] = status | |
reversion_data[‘slot_id'] = slot_id | |
# ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT r.date_created, u.first_name, u.last_name, v.serialized_data | |
FROM reversion_revision r JOIN auth_user u ON r.user_id=u.id JOIN reversion_version v ON v.revision_id=r.id WHERE v.object_id_int=123456 AND v.content_type_id=78 ORDER BY r.date_created asc; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MIDDLEWARE_CLASSES = ( | |
#... | |
‘reversion.middleware.RevisionMiddleware’, | |
#... | |
) | |
INSTALLED_APPS = [ | |
#... | |
‘reversion’ | |
#... | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pip install django-reversion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
reversion_revision | |
reversion_version |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment