Skip to content

models

TimeStampMixin

Bases: Model

This class is a mixin that adds created_at and updated_at fields to any model that inherits from it.

Source code in backend/shared/models.py
 4
 5
 6
 7
 8
 9
10
11
12
13
14
class TimeStampMixin(models.Model):
    """
    This class is a mixin that adds created_at and updated_at fields to any model that inherits from it.
    """
    created_at = models.DateTimeField(auto_now_add=True, editable=False)
    """The date and time when the object was created."""
    updated_at = models.DateTimeField(auto_now=True)
    """The date and time when the object was last updated."""

    class Meta:
        abstract = True

created_at = models.DateTimeField(auto_now_add=True, editable=False) class-attribute instance-attribute

The date and time when the object was created.

updated_at = models.DateTimeField(auto_now=True) class-attribute instance-attribute

The date and time when the object was last updated.