#12315: DateField incorrectly handled by administration site ---------------------------------------------------+------------------------ Reporter: toplex | Owner: nobody Status: new | Milestone: Component: Uncategorized | Version: 1.1 Keywords: date DateField admin date_hierarchy | Stage: Unreviewed Has_patch: 0 | Needs_docs: 0 Needs_tests: 0 | Needs_better_patch: 0 ---------------------------------------------------+------------------------ I followed the Django guide in creating a Polls website, and I encountered a strange, but funny bug in the automatically created administration site.
The problematic model: {{{ class Poll(models.Model): question = models.CharField(max_length=200) pub_date = models.DateTimeField('date published') def was_published_today(self): return self.pub_date.date() == datetime.date.today() was_published_today.short_description = "Published today?" def __unicode__(self): return self.question }}} The problematic admin object: {{{ class PollAdmin(admin.ModelAdmin): fieldsets = [ (None, {'fields': ['question']}), ('Date information', {'fields': ['pub_date'], 'classes': ['collapse']}) ] inlines = [ChoiceInLine] list_display = ('question', 'pub_date', 'was_published_today') list_filter = ['pub_date'] search_fields = ['question'] date_hierarchy = 'pub_date' }}} I was going through the admin guide, and it was passed midnight (well, just like now). I played around with the admin site, as I noticed something strange - a poll I added with today's date (the new day), returned False in the ''was_published_today'' method. I figured something funny is going on, so I played with the date hierarchy, and strangely (but expected), the hierarchy thing did not count this Poll object as today either - in fact, I had to go all the way back to ''This month'' filter to see it (I guessed the ''Today'' and ''Passed 7 days'' use a different checking method which involved a faulty subtracting, where as the ''This month'' and ''This year'' just compares). I added useful screen shots - The date can be found at the top right of the screen, and the time (fuzzily) at the bottom (thank god for KDE's awesome plasmoids). -- Ticket URL: <http://code.djangoproject.com/ticket/12315> 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-upda...@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.