Created
August 23, 2013 13:59
-
-
Save anonymous/6319615 to your computer and use it in GitHub Desktop.
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
From 6d9caf48de855a39cb3f5b229cccda1fa7dcfe46 Mon Sep 17 00:00:00 2001 | |
From: Quentin Pradet <quentin.pradet@gmail.com> | |
Date: Fri, 23 Aug 2013 15:52:41 +0200 | |
Subject: [PATCH] Include full instructions to get started | |
--- | |
Home.md | 26 +++++++++++++++++--------- | |
1 file changed, 17 insertions(+), 9 deletions(-) | |
diff --git a/Home.md b/Home.md | |
index 8f12fd5..4ee1649 100644 | |
--- a/Home.md | |
+++ b/Home.md | |
@@ -3,19 +3,16 @@ Getting started with django-reversion | |
To install django-reversion, follow these steps: | |
-1. Checkout the latest django-reversion release and copy or symlink the `src/reversion` directory into your `PYTHONPATH`. | |
-2. Add `'reversion'` to your `INSTALLED_APPS` setting. | |
-3. Run the command `manage.py syncdb`. | |
- | |
-The latest release (1.7.1) of django-reversion is designed to work with Django 1.5. If you have installed anything other than the latest version of Django, please check the [[compatible Django versions]] page before downloading django-reversion. | |
- | |
-There are a number of alternative methods you can use when installing django-reversion. Please check the [[installation methods]] page for more information. | |
+1. Install from PyPI: `pip install django-reversion` (to install manually, see [[installation methods]]). | |
+2. Add `'reversion'` to `INSTALLED_APPS`. | |
+3. Run `./manage.py syncdb`. | |
+The latest release (1.7.1) of django-reversion is designed to work with Django 1.5. For other Django versions, check the [[compatible Django versions]] page. | |
Admin integration | |
----------------- | |
-django-reversion can be used to add a powerful rollback and recovery facility to your admin site. To enable this, simply register your models with a subclass of `reversion.VersionAdmin`. | |
+django-reversion adds a powerful rollback and recovery facility to your admin site. To enable this, simply register your models with a subclass of `reversion.VersionAdmin` in admin.py: | |
```python | |
import reversion | |
@@ -29,8 +26,19 @@ admin.site.register(YourModel, YourModelAdmin) | |
Whenever you register a model with the `VersionAdmin` class, be sure to run the `./manage.py createinitialrevisions` command to populate the version database with an initial set of model data. Depending on the number of rows in your database, this command could take a while to execute. | |
-For more information about admin integration, please visit the [[admin integration]] wiki page. | |
+To save a new revision for every save() in the database, the simplest way is to add those two classes to `MIDDLEWARE_CLASSES`: | |
+ | |
+``` | |
+MIDDLEWARE_CLASSES = ( | |
+ # Your middlewares... | |
+ 'django.middleware.transaction.TransactionMiddleware', | |
+ 'reversion.middleware.RevisionMiddleware' | |
+) | |
+``` | |
+The first one makes sure data is only saved if the request completed succesfully, ensuring data integrity. The second one automatically commits a new revision is this is the case. Order is important. | |
+ | |
+For more information about admin integration, please visit the [[admin integration]] wiki page. | |
Low Level API | |
------------- | |
-- | |
1.8.3.4 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment