On Sat, 2007-07-07 at 20:57 +0300, Andrey Khavryuchenko wrote:
> Hi!
> 
> Had anyone noticed that loading DateField and DateTimeField from sqlite
> in-memory db results in getting plain strings instead of datetime objects?
> 
> Code:
> 
>         f = models.Feed(feed_url='no such url', is_active=True)
>         f.save()
>         post = models.Post(feed = f, title='test post', link=self.url)
>         post.save()
>         
>         assert models.Feed.objects.count() == 1, 'should be single feed'
>         assert models.Post.objects.count() == 1, 'should be single post'
>         
>         print '!!!', type(post.date_created), \
>               models.Post.objects.all()[0].date_created, \
>               type(models.Post.objects.all()[0].date_created)
>         assert type(models.Post.objects.all()[0].date_created) == \
>                type(post.date_created)
> 
> It prints the following and fails on last assert:
> 
> -------------------- >> begin captured stdout << ---------------------
> !!! <type 'datetime.datetime'> 2007-07-07 <type 'unicode'>
> 
> --------------------- >> end captured stdout << ----------------------
> 
> While I'm digging in sqlite backend sources, may anyone share his
> experience?

I just tried this with some models I have here using sqlite and they all
loaded DateTime fields as Python datetime instances. Saving and
reloading didn't seem to change the type, either.

So this doesn't seem to be a universal failure. Would be interesting to
know what's going on, though.

Regards,
Malcolm


-- 
The early bird may get the worm, but the second mouse gets the cheese. 
http://www.pointy-stick.com/blog/


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to