I would just have 2 fields on the model, one for the created ones and one that records the updated time like this
class Location(models.Model): created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True)
If you use django-model-utils, you can subclass TimeStampedModel, which has both created and modified fields.
#Django model utils TimeStampedModel class TimeStampedModel(models.Model): """ An abstract base class model that provides self-updating ``created`` and ``modified`` fields. """ created = AutoCreatedField(_('created')) modified = AutoLastModifiedField(_('modified')) class Meta: abstract = True class Location(TimeStampedModel): """ Add additional fields """
source share