django does django have an automatic timestamp create/update field like cakephp?

后端 未结 2 1703
梦如初夏
梦如初夏 2021-02-07 08:36

having used cakephp in the past, one thing (perhaps the only thing?) i liked about it was that it had a \"create\" and \"update\" timestamp capability that was lovely - simply p

2条回答
  •  天命终不由人
    2021-02-07 09:08

    It is not added to your model built-in in every table. You must add it as field to your model.

    class Message(models.Model):
    
        created_at = models.DateTimeField(auto_now_add=True)
        updated_at = models.DateTimeField(auto_now=True)
    

    Message in this case your table's name.

提交回复
热议问题