Re: [Django] #16421: Serializing TimeField throws Attribute Error

2011-07-07 Thread Django
#16421: Serializing TimeField throws Attribute Error
-+-
   Reporter: |  Owner:  nobody
  silent1mezzo   | Status:  closed
   Type:  Bug|  Component:  Database layer
  Milestone: |  (models, ORM)
Version:  1.3|   Severity:  Normal
 Resolution: |   Keywords:
  worksforme |  Has patch:  1
   Triage Stage: |Needs tests:  0
  Unreviewed |  Easy pickings:  0
Needs documentation:  0  |
Patch needs improvement:  0  |
  UI/UX:  0  |
-+-
Changes (by aaugustin):

 * status:  new => closed
 * needs_docs:   => 0
 * resolution:   => worksforme
 * needs_tests:   => 0
 * needs_better_patch:   => 0


Comment:

 I can't reproduce. I've written a test case, which I'm attaching to this
 ticket. I later noticed that the serialization of `TimeField`s is already
 tested by the `serializers_regress` tests.

 Also, I believe you patch is wrong:
 - `val` is supposed to be a time object or `None`, not a string; if the
 function is called with a string, the error must be fixed in the caller,
 or further up the stack.
 - when `val` is a time object, the function returns a string; but with you
 patch, when `val` is a string, you're returning a time object. I don't
 understand this at all.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



[Django] #16421: Serializing TimeField throws Attribute Error

2011-07-05 Thread Django
#16421: Serializing TimeField throws Attribute Error
--+--
 Reporter:  silent1mezzo  |  Owner:  nobody
 Type:  Bug   | Status:  new
Milestone:|  Component:  Database layer (models, ORM)
  Version:  1.3   |   Severity:  Normal
 Keywords:|   Triage Stage:  Unreviewed
Has patch:  1 |  Easy pickings:  0
UI/UX:  0 |
--+--
 Affects version 1.2.x, 1.3

 Model:
 {{{
 class TestModel(models.Model):
 test_time = models.TimeField()
 }}}

 Stack Trace
 {{{
 File "/home/webdev/web/virtualenvs/polaris/lib/python2.6/site-
 packages/django/core/serializers/__init__.py", line 87, in serialize
 s.serialize(queryset, **options)
   File "/home/webdev/web/virtualenvs/polaris/lib/python2.6/site-
 packages/django/core/serializers/base.py", line 45, in serialize
 self.handle_field(obj, field)
   File "/home/webdev/web/virtualenvs/polaris/lib/python2.6/site-
 packages/django/core/serializers/python.py", line 45, in handle_field
 self._current[field.name] = field.value_to_string(obj)
   File "/home/webdev/web/virtualenvs/polaris/lib/python2.6/site-
 packages/django/db/models/fields/__init__.py", line 1103, in
 value_to_string
 data = val.strftime("%H:%M:%S")
 AttributeError: 'unicode' object has no attribute 'strftime'
 }}}

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.