Automatic Created and Updated DateTime Fields for Django Models

Jan 26, 2018 · by Tim Kamanin

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)


Want to get more 🔥 tips like this one?

Subscribe to get notified about new dev tutorials