chevron_left chevron_right
Login Register invert_colors photo_library

Stay updated and chat with others! - Join the Discord!
Thread Rating:
  • 0 Vote(s) - 0 Average

Saving Django model with DateTime fields filter_list
Saving Django model with DateTime fields #1
Hi! I have a model that looks like this:
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 file:
USE_TZ = True
So what's the problem here? How do I make Django save collection_from value the same way as created_at or updated_at?


Users browsing this thread: 1 Guest(s)