#24822: DateTimeField timezone issue converting default fields
------------------------------+--------------------
     Reporter:  camiloforero  |      Owner:  nobody
         Type:  Bug           |     Status:  new
    Component:  Migrations    |    Version:  1.8
     Severity:  Normal        |   Keywords:
 Triage Stage:  Unreviewed    |  Has patch:  0
Easy pickings:  0             |      UI/UX:  0
------------------------------+--------------------
 I wanted to add a default value to a DateTimeField, so I set {{{
 default=datetime(2015, 7, 4, 8, 0 ) }}} as an argument. When I ran
 makemigrations/migrate, I got a warning about naive timezones. I read
 about it and decided to set it as {{{ default=datetime(2015, 7, 4, 8, 0,
 tzinfo=timezone.get_default_timezone() ) }}} (I imported
 django.utils.timezone) but when I tried to makemigrations and migrate I
 got an error {{{ can't compare offset-naive and offset-aware datetimes }}}
 from {{{old_field_dec != new_field_dec}}} in django.autodetector.py.
 To solve it I had to remove the default from the DateTimeField, migrate
 (got a warning again), add it again with the timezone enabled, and migrate
 again. That time it worked just fine.
 It is worth noting that all of the fields currently in the database had
 their values already set, that I am using PostgreSQL and python 2.7.3

--
Ticket URL: <https://code.djangoproject.com/ticket/24822>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/055.2b17f59701a28bac756c5e9330f8384a%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to