models.TimeField returning string rather than datetime.time with MySQL backend

2012-02-26 Thread smcoll
i need to interact with an existing MySQL database table, so i built a
models.py file in a new app via introspection and then cleaned it up a
bit.  For the TIME types, i am using models.TimeField, which maps to a
TIME type when using the MySQL backend.

Here's a sample from that models.py file:

http://dpaste.com/hold/708356/

What's strange is that when i'm accessing that `time_of_day` field,
it's returning as a string rather than a datetime.time:

>>> from reporting.models import FooModel
>>> m = FooModel.objects.latest()
>>> m.time_of_day
'09:19:00'

To be sure of the expected behavior, i set up a mock project with a
corresponding MySQL database on the same server.  models.py:

http://dpaste.com/hold/708357/

Now, when i grab that `time` field, i get a datetime.time, which is
the expected behavior (note the final line):

>>> from timetest.models import Widget
>>> w = Widget.objects.latest()
>>> w.now
datetime.datetime(2012, 2, 25, 18, 45, 8)
>>> w.datetime
datetime.datetime(2012, 1, 1, 1, 23, 45)
>>> w.date
datetime.date(2012, 2, 2)
>>> w.time
datetime.time(12, 34, 56)

i haven't been able to explain the difference in behavior.  The only
differences between the two databases and their respective tables that
i can think of are:
 - the introspected database and tables weren't created by the Django
ORM
 - the introspected tables are InnoDB and the Django-generated tables
are MyISAM
 - introspected table row format are "compact" and Django-generated
row format are "fixed"

Using 1.3.X. Any idea what's going on?

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



Re: models.TimeField()

2007-02-27 Thread Honza Král
On 2/28/07, DuncanM <[EMAIL PROTECTED]> wrote:
>
> When you use this field type, django automatically places a clock next
> to the field which is very handy with quick links: 6am, noon,
> midnight, now() or something similar.
>
> Is there any way I can get the list that is displayed then to be set
> values? such as 10am, noon and 2pm? or will I have to rely on my users
> to type it in?

these values are hardwired to the admin javascript (see DateTimeShortcuts.js)
>
> TIA,
> Duncan
>
>
> >
>


-- 
Honza Kr�l
E-Mail: [EMAIL PROTECTED]
ICQ#:   107471613
Phone:  +420 606 678585

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



models.TimeField()

2007-02-27 Thread DuncanM

When you use this field type, django automatically places a clock next
to the field which is very handy with quick links: 6am, noon,
midnight, now() or something similar.

Is there any way I can get the list that is displayed then to be set
values? such as 10am, noon and 2pm? or will I have to rely on my users
to type it in?

TIA,
Duncan


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