Ian George committed ba081f4

Moved change_date from auto_now=True to being updated on save()

Comments (0)

Files changed (1)


+from datetime import datetime
 from django.db import models
 from django.contrib.contenttypes.models import ContentType
 from django.contrib.contenttypes import generic
     # log of to / from, state info, date, user
     from_state = models.CharField(max_length=150, db_index=True)
     to_state = models.CharField(max_length=150, db_index=True)
-    change_date = models.DateTimeField(auto_now=True, db_index=True)
+    change_date = models.DateTimeField(db_index=True)
     user = models.ForeignKey(User, null=True, blank=True)
     #optional notes
     notes = models.CharField(max_length=500, null=True, blank=True)
+    def save(self, *args, **kwargs):
+        ''' On save, update timestamps, stopped using auto_now because I wanted it editable in admin '''
+        self.change_date =
+        return super(StateMachineHistory, self).save(*args, **kwargs)
 class StateMachineWithHistory(models.Model):