Skip to content

Instantly share code, notes, and snippets.

@DataGreed
Created April 5, 2022 15:56
Show Gist options
  • Save DataGreed/d45c97ef1f322b35c110320941fbe26f to your computer and use it in GitHub Desktop.
Save DataGreed/d45c97ef1f322b35c110320941fbe26f to your computer and use it in GitHub Desktop.

Revisions

  1. DataGreed renamed this gist Apr 5, 2022. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. DataGreed created this gist Apr 5, 2022.
    11 changes: 11 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    class BaseModel(models.Model):
    """
    Base abstract model that adds created and modified dates.
    Inherit from it when defining models.
    """

    class Meta:
    abstract = True

    date_created = models.DateTimeField("Date Created", auto_now_add=True)
    date_modified = models.DateTimeField("Date Modified", auto_now=True)