In django do models have a default timestamp field?

前端 未结 6 1322
误落风尘
误落风尘 2021-01-30 09:53

In django - is there a default timestamp field for all objects? That is, do I have to explicitly declare a \'timestamp\' field for \'created on\' in my Model - or is there a way

6条回答
  •  深忆病人
    2021-01-30 10:38

    You can try django-extensions

    if you want to use time-stamp abstract model

    from django_extensions.db.models import TimeStampedModel
    
    class A(TimeStampedModel):
       ...
    

    It has other abstract models. you can use that too.

提交回复
热议问题