Created
April 5, 2022 15:56
-
-
Save DataGreed/d45c97ef1f322b35c110320941fbe26f to your computer and use it in GitHub Desktop.
base model for Django projects with autopopulated date_created and date_modified fields
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment