dates DateQuerySet includes time

9 views
Skip to first unread message

Chad Vernon

unread,
Oct 15, 2013, 8:56:01 PM10/15/13
to django...@googlegroups.com
I'm trying to use the dates QuerySet method but I am getting different values in the template:

view:
timecards = Timecard.objects.all()
dates = Timecard.objects.dates('date', 'day', order='DESC')


template:
{% for tc in timecards %}
  {{ tc.date }}
{% endfor %}

Oct. 14, 2013

{% for d in dates %}
  {{ d }}
{% endfor %}

Oct. 13, 2013, 5 p.m.

The documentation says dates is supposed to return a datetime.date object, so there should not be any time.  So where does the 5 p.m. come from?  Also I'm assuming the day difference is due to time zone which comes with time.  So am I using the dates method correctly?

Thanks,
Chad

Chad Vernon

unread,
Oct 15, 2013, 9:03:11 PM10/15/13
to django...@googlegroups.com
I'm using django 1.5.1 and I guess in in 1.5, the dates method returns datetime objects.  So nevermind!
Reply all
Reply to author
Forward
0 new messages