In django django is there an automatic creation / updating of a timestamp field like cakephp?

using cakephp in the past, one thing (maybe the only thing?), I liked that she had the ability to create a β€œcreate” and β€œupdate” timestamp, which was beautiful - just put it when you first added the item, the creation date was installed (assuming you named it correctly - create_date, I think)

At any time after this, if the update was completed, the β€œupdate” field was set to the current time.

Does django have this? If so, what / how can I name the fields to make them pick them up?

+5
source share
2 answers

I am sure that there is!

auto_now auto_now_add

+14

, . .

class Message(models.Model):

    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

.

+8

All Articles