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)


Hey, if you've found this useful, please share the post to help other folks find it:

There's even more:

Subscribe for updates

  • via Twitter: @timonweb
  • old school RSS:
  • or evergreen email ↓ ↓ ↓