Created
September 7, 2017 09:00
-
-
Save phalt/6f5e45a3dc9a308e1f4708fd48ce35c2 to your computer and use it in GitHub Desktop.
Abstract Base models
This file contains 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
from django.db import models | |
class DateTimeModel(models.Model): | |
class Meta: | |
abstract = True | |
date_created = models.DateTimeField(auto_now_add=True) | |
date_updated = models.DateTimeField(auto_now=True) |
This file contains 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
from abstract import DateTimeModel | |
class MyModel(DateTimeModel): | |
foo = models.CharField() | |
''' | |
This model above will have date_created and date_updated added to it! | |
''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment