Saving Django model with DateTime fields 08-21-2016, 12:45 PM
#1
Hi! I have a model that looks like this:
Now, when I'm saving it's instances the created_at and updated_at values are set properly, eg: 2016-08-21 13:13:57.585472+02. collection_from value should be nearly the same as those two previous ones, but it's getting set to point to the next day, eg: 2016-08-22 01:00:00+02 which I don't get at all. The collection_from value looks like that when sent by the browser: 2016-08-21 23:00. I believe I have proper settings set up in the settings.py file:
So what's the problem here? How do I make Django save collection_from value the same way as created_at or updated_at?
Code:
class Meal(models.Model):
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
collection_from = models.DateTimeField(blank=False, null=False)
discount_price = models.DecimalField(blank=False, null=False, decimal_places=2, max_digits=4)
normal_price = models.DecimalField(blank=True, null=True, decimal_places=2, max_digits=4)
available_count = models.IntegerField(blank=False, null=False)
name = models.CharField(blank=False, null=False, max_length=255)
active = models.BooleanField(blank=False, null=False, default=True)Now, when I'm saving it's instances the created_at and updated_at values are set properly, eg: 2016-08-21 13:13:57.585472+02. collection_from value should be nearly the same as those two previous ones, but it's getting set to point to the next day, eg: 2016-08-22 01:00:00+02 which I don't get at all. The collection_from value looks like that when sent by the browser: 2016-08-21 23:00. I believe I have proper settings set up in the settings.py file:
Code:
TIME_ZONE = 'UTC'
USE_TZ = True

![[+]](https://sinister.li/images/modern/collapse_collapsed.png)