没有正确的主张和错误

时间:2019-05-13 05:19:59

标签: django

错误->>>预期的字符串或类似字节的对象

我知道这是怎么回事

models.py->>

      publish_date = models.DateTimeField(auto_now =True, auto_now_add =  False, null =True)
      timestamp = models.DateTimeField( auto_now_add = True, )
      updated = models.DateTimeField(auto_now =True)

2 个答案:

答案 0 :(得分:0)

您不应同时使用auto_nowauto_now_add

publish_date = models.DateTimeField(auto_now =True, null =True)
timestamp = models.DateTimeField(auto_now_add = True )

答案 1 :(得分:0)

您不能同时使用auto_now和auto_now_add,因为它们是互斥的。

publish_date = models.DateTimeField(auto_now =True, null =True)
timestamp = models.DateTimeField( auto_now = True, )
updated = models.DateTimeField(auto_now =True)