#29395: Assigning correctly formatted time string to TimeField field works, but
leaves the field value a string (and not datetime.time as when retrieved)
-------------------------------------+-------------------------------------
               Reporter:  Tomer      |          Owner:  nobody
  Zekharya                           |
                   Type:  Bug        |         Status:  new
              Component:  Database   |        Version:  2.0
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 When initializing a TimeField field with a well formatted time string (i.e
 '12:00:00') and saving the object, it works fine, but leaves the field as
 'str' type and does not convert it to a datetime.time object. This creates
 an inconsistency, where newly saved objects may have 'str' values for
 TimeField fields, while retrieved objects have datetime.time values. The
 docs clearly state that TimeField field in Django is represented as
 datetime.time object in python.

 For example:

 models.py
 {{{
 from django.db import models

 class A(models.Model):
     time = models.TimeField()
 }}}

 And when using this model as described above:

 {{{

 >>> t = A(time='12:10:00')
 >>> t.save()
 >>> type(t.time)
 <class 'str'>

 >>> t2 = A.objects.get(id=t.id)
 >>> type(t2.time)
 <class 'datetime.time'>

 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/29395>
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/049.0e8af8cd88989ae9eeaf1381f1323f06%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to