Skip to content

Instantly share code, notes, and snippets.

@ishahid
Last active December 24, 2015 06:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ishahid/6759595 to your computer and use it in GitHub Desktop.
Save ishahid/6759595 to your computer and use it in GitHub Desktop.
An abstract base class model for Django that provides self-updating 'created' and 'modified' fields.
from django.db import models
class TimeStampedModel(models.Model):
"""
An abstract base class model that provides self-updating 'created'
and 'modified' fields.
"""
created = models.DateTimeField(auto_now_add=True)
modified = models.DateTimeField(auto_now=True)
class Meta:
abstract = True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment