In one of my model I am storing time_stamp = models.DateTimeField(default=timezone.now)
But when I save the model it says You are 5.5 hours ahead of server time.
for example local time in my machine is 13:02
but after saving what gets stored in db is 7:16
I got one related here but it does not an have a satisfying answer...
models.py
class Comment(models.Model):
time_stamp = models.DateTimeField(default=timezone.now)
def save(self, *args, **kwargs):
''' On save, update timestamps '''
if not self.id:
self.time_stamp = timezone.now()
return super(Comment, self).save(*args, **kwargs)
As you are 5.5 hrs ahead of server time, I am assuming, you are in India.
So put appriopriate timezone in settings.py
TIME_ZONE = 'Asia/Kolkata'
If somewhere else, set accordingly
Make sure you make the following change in the settings.py file in your Django project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With