티스토리 뷰

공부

[Django] created_at, updated_at

seunggabi 승가비 2020. 7. 9. 02:35
class MyModel(models.Model):
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

https://stackoverflow.com/questions/3429878/automatic-creation-date-for-django-model-form-objects

 

Automatic creation date for Django model form objects?

What's the best way to set a creation date for an object automatically, and also a field that will record when the object was last updated? models.py: created_at = models.DateTimeField(False, True,

stackoverflow.com

 

'공부' 카테고리의 다른 글

[Django] remove prefix app name for table  (0) 2020.07.09
[PyCharm] PYTHONPATH=  (0) 2020.07.09
[Django] created_at, updated_at  (0) 2020.07.09
[Sh] "" == true ? -> if [ -z "$VAR" ];  (0) 2020.07.09
[Jenkins] executors take up a lot of memory  (0) 2020.07.09
[Sh] if  (0) 2020.07.04
댓글
댓글쓰기 폼