Answer the question
In order to leave comments, you need to log in
The created_at field after the record is changed, the date decreases by one day. Why?
Django field created_at after the record is changed, the date decreases by one day. Why?
created_at = models.DateTimeField(default=datetime.now)
updated_at = models.DateTimeField()
def save(self, *args, **kwargs):
auto_now = kwargs.pop('updated_at_auto_now', True)
if auto_now:
self.updated_at = datetime.now()
super(Mk, self).save(*args, **kwargs)
Answer the question
In order to leave comments, you need to log in
https://docs.djangoproject.com/en/1.10/ref/models/...
#
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question