#32147: timezone error when casting a naive date in a Daylight Saving Time 
Change
--------------------------------------+--------------------------
               Reporter:  WolfTammer  |          Owner:  nobody
                   Type:  Bug         |         Status:  assigned
              Component:  Utilities   |        Version:  3.1
               Severity:  Normal      |       Keywords:  timezone
           Triage Stage:  Unreviewed  |      Has patch:  0
    Needs documentation:  0           |    Needs tests:  0
Patch needs improvement:  0           |  Easy pickings:  0
                  UI/UX:  0           |
--------------------------------------+--------------------------
 When you use a model with datetime with a timezone active and naive data
 as input, it raise the follow error:

 {{{
 File "<basepath>/lib/python3.7/site-packages/pytz/tzinfo.py", line 234, in
 localize
     raise AmbiguousTimeError(dt)
 pytz.exceptions.AmbiguousTimeError: 2020-10-25 02:00:01
 }}}

 The steps to reproduce are:

 1. '''Use a model with datetime''': In this example, we are going to
 create a user model that extends AbstractUser, but you could use any model
 with a datetime field

 {{{
 class User(AbstractUser):
     class Meta:
         db_table = 'my_user'

     created_at = models.DateTimeField(default=timezone.now)
     updated_at = models.DateTimeField(auto_now=True)
     last_password_change = models.DateTimeField(null=True)
 }}}

 2. '''Create an object with a string naive date''':

 {{{
     User.objects.create(
         email = "[email protected]",
         username = "user_25",
         created_at = "2020-10-25 02:00:01"
     )
 }}}

 * The timezone settings are:
 TIME_ZONE = 'Europe/Rome'
 USE_TZ = True

 Database configuration has not timezone set

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32147>
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/049.65dc09304e3cf1a16f244df149946229%40djangoproject.com.

Reply via email to