django做django有一个自动时间戳创建/更新字段像cakephp? [英] django does django have an automatic timestamp create/update field like cakephp?
问题描述
此后,如果执行更新,更新字段为设置为当前时间。
还有django吗?如果是这样,我怎么命名字段来接收它们?
确实有!在 auto_now 和 ://docs.djangoproject.com/en/dev/ref/models/fields/#datetimefield>该文档 auto_now_add
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 put, when you first added an item, the "create" date was set (assuming you named it right - create_date, i think)
Anytime thereafter, if an update was performed, the "update" field was set to the current time.
Does django have this as well? If so, what/how do i name the fields to get it to pick them up?
Sure it has!
Check auto_now
and auto_now_add
in the doc
这篇关于django做django有一个自动时间戳创建/更新字段像cakephp?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!