Added version history to models with the use of a mixin

This commit is contained in:
Tom Price
2014-11-04 03:27:32 +00:00
parent 31488da8b5
commit a7384c1dd2
5 changed files with 29 additions and 7 deletions

View File

@@ -7,7 +7,9 @@ django.setup()
from django.db import connections
from django.core.exceptions import ObjectDoesNotExist
from django.db.utils import ConnectionDoesNotExist
from django.db import transaction
from RIGS import models
import reversion
def setup_cursor():
try:
@@ -40,6 +42,8 @@ def import_people():
person, created = models.Person.objects.get_or_create(pk=row[0], name=row[1], phone=row[2], email=email, address=row[4], notes=notes)
if created:
print("Created: " + person.__unicode__())
with transaction.atomic(), reversion.create_revision():
person.save()
else:
print("Found: " + person.__unicode__())