#11851: .annotate() turns datetime fields to unicode with sqlite3 ------------------------------------------+--------------------------------- Reporter: aminc | Owner: nobody Status: new | Milestone: Component: Database layer (models, ORM) | Version: 1.1 Keywords: | Stage: Unreviewed Has_patch: 0 | ------------------------------------------+--------------------------------- I have two models, joined with a !ManyToManyField: {{{ class MainModel(models.Model): date = models.DateTimeField(auto_now_add=True) others = models.ManyToManyField('OtherModel')
class OtherModel(models.Model): pass }}} I set up a sample dataset: {{{ >>> m = MainModel.objects.create() >>> for i in range(12): >>> ... m.others.create() }}} But when I use queryset annotation, my !DateTimeField is giving me the raw unicode value: {{{ >>> MainModel.objects.annotate(num_others=Count('others')).get().date u'2009-09-08 12:54:17.380000' >>> MainModel.objects.get().date datetime.datetime(2009, 9, 8, 12, 54, 17, 380000) }}} These are my sqlite tables: {{{ sqlite> .schema news_mainmodel CREATE TABLE "news_mainmodel" ( "id" integer NOT NULL PRIMARY KEY, "date" datetime NOT NULL ); sqlite> .schema news_othermodel CREATE TABLE "news_othermodel" ( "id" integer NOT NULL PRIMARY KEY ); }}} -- Ticket URL: <http://code.djangoproject.com/ticket/11851> Django <http://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 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 -~----------~----~----~----~------~----~------~--~---