Automatic Created and Updated DateTime Fields for Django Models

26 Jan · by Tim Kamanin · 1 min read

I'm leaving this to my future self, as I keep forgetting it over and over again.

If you want to add "create" and "update" time logging to your model, it's as simple as:

from django.db import models

class Task(models.Model):
    created = models.DateTimeField(auto_now_add=True)
    updated = models.DateTimeField(auto_now=True)