On 14 avr. 2012, at 21:25, Evan Carmi wrote: > >>> Poll.objects.filter(pub_date__year=1) #We should get the poll p (but we > >>> don't) > []
The docs [1] say that the __year lookup "takes a four digit year". I'm not sure what this means exactly for years < 1000! It looks like it's possible to improve either the code or the docs, so it's worth filing a ticket in Trac. > The SQL queries that are being generated are (for sqlite): > {'sql': u'INSERT INTO "polls_poll" ("question", "pub_date") VALUES (Year is > 999, 0999-09-09 00:00:00)', > 'time': '0.043'}, > {'sql': u'SELECT "polls_poll"."id", "polls_poll"."question", > "polls_poll"."pub_date" FROM "polls_poll" WHERE "polls_poll"."pub_date" > BETWEEN 999-01-01 and 999-12-31 23:59:59.999999 LIMIT 21', > 'time': '0.000'}] Note that these aren't the actual SQL queries [2]. Stiil, they likely show the cause of the problem. Best regards, -- Aymeric. [1] https://docs.djangoproject.com/en/1.4/ref/models/querysets/#year [2] https://docs.djangoproject.com/en/1.4/ref/databases/#parameters-not-quoted-in-connection-queries -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.