title: Is Django corrupting timezone-aware DateTimeField when saving it to the Database?
body: <p>I have a Django model as described <a href="https://stackoverflow.com/questions/31275987/how-to-write-django-queryset-to-get-unix-timestamp-of-a-datetimefield"><strong>here</strong></a></p>
  
  <p>I create and save an instance of this model:</p>
  
  <pre><code>&gt;&gt;&gt; from django.db.models import Max, F, Func
  &gt;&gt;&gt; from django.conf import settings
  &gt;&gt;&gt; import pytz, datetime
  &gt;&gt;&gt; from myapp.models import myModel
  
  &gt;&gt;&gt; myModel.objects.all().delete()
  
  &gt;&gt;&gt; myModel.objects.create(
      my_date=datetime.datetime(2037,4,2,15,18,17,tzinfo=pytz.UTC), 
      my_string="asda"
  )
  &lt;myModel: myModel object&gt;
  </code></pre>
  
  <p>Then I try to retrieve the instance I just inserted, but I get the DateTimeField in native format and after applying <code>UNIX_TIMESTAMP</code>:</p>
  
  <pre><code>&gt;&gt;&gt; x = myModel.objects.values('my_string').aggregate(
      max1=Max('my_date'), 
      max2=Max(Func(F('my_date'), function='UNIX_TIMESTAMP'))
  )
  
  &gt;&gt;&gt; x
  {
      'max2': Decimal('2122848857.000000'), 
      'max1': datetime.datetime(2037, 4, 8, 20, 14, 17, tzinfo=&lt;UTC&gt;)
  }
  
  &gt;&gt;&gt; datetime.datetime.utcfromtimestamp(x["max2"])
  datetime.datetime(2037, 4, 9, 0, 14, 17)
  
  
  &gt;&gt;&gt; pytz.timezone(settings.TIME_ZONE)
  &lt;DstTzInfo 'America/New_York' LMT-1 day, 19:04:00 STD&gt;
  &gt;&gt;&gt; 
  </code></pre>
  
  <p>If you <a href="http://www.unixtimestamp.com/index.php" rel="nofollow noreferrer">convert</a> <code>2122848857</code> back to a DateTime, you get <code>2037-04-09T00:14:17+00:00</code>. This is 4 hours greater than the time I actually inserted. Why? How to correct this seeming corruption? My machine's timezone is EDT which is 4 hours behind UTC. But that still doesn't explain why Django is saving this UTC time as if it was in my local timezone.</p>