0
我有一個Comment
模型。它具有以下時間戳字段:Django的DateTimeField的「auto_now」似乎不起作用
created = models.DateTimeField(auto_now_add=True, blank=True, null=True)
last_edit = models.DateTimeField(auto_now=True, blank=True, null=True)
現在,當我使用這種格式更新評論:Comment.objects.filter(...).update(text="some new text")
,在last_edit
領域沒有得到,而註釋的文本也得到更新更新。有什麼問題?
更新:此外,我正在使用filter
,因爲update
不適用於get
,即Comment.objects.get(...).update(...)
不起作用。我實際上想要做的是get
,因爲我確信只有一條評論需要一次更新。