Why does django-lint tell me the `auto_now_add` is deprecated?

后端 未结 2 891
花落未央
花落未央 2021-01-02 11:01

Hi fellow Djangonauts:

I checked my project with django-lint, and it yields:

W:211,16:MyModel: timestamp: Uses superceded auto_now or auto_now_add
         


        
2条回答
  •  情书的邮戳
    2021-01-02 11:34

    The correct fix is to pass a callable as the field's default that returns the appropriate datetime, e.g. datetime.datetime.now.

提交回复
热议问题