Z
Z
zkweb2016-11-07 11:05:09
Django
zkweb, 2016-11-07 11:05:09

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

2 answer(s)
S
sim3x, 2016-11-07
@sim3x

https://docs.djangoproject.com/en/1.10/ref/models/...

#
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

set server locale correctly

A
Abdulla Mursalov, 2016-11-07
@amaprograma

Googled for you
here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question