Reputation: 13
I'm trying to have an immutable field(created_at) and be able to update it(updated_at) without altering the original created_at field. This is a django project if that matters
Upvotes: 1
Views: 614
Reputation: 1625
Use auto_now
and auto_now_add
(see documentation).
class Book(models.Model):
...
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
Upvotes: 2