Why does django date filter gives me entries from the next day as welll
<p>I am trying to access a database which has say two entries for 2016,9,25 and two entries for 2016,9,26, each of those entries have different time... I view them by listing each of them using the task.start_time in my template following is the list that I get</p>

<pre><code>TASK        Task.title                  duration    start_time                  project     project_color   user
1st task    This is the first task      0:02:40     Sept. 25, 2016, 11:42 p.m.  Unassigned  NO COLOR    faizank
2nd task    This is the second task     0:01:30     Sept. 25, 2016, 11:47 p.m.  Unassigned  NO COLOR    faizank
3rd task    asdasdasdasd                0:20:00     Sept. 26, 2016, 12:19 a.m.  Unassigned  NO COLOR    faizank
3rd task    this is the problem         0:20:00     Sept. 26, 2016, 12:22 a.m.  Unassigned  NO COLOR    faizank
</code></pre>

<p>start_time is a datetime_field, now i am filtering the datetime object using the following queries</p>

<pre><code>&gt;&gt;&gt; c= Task.objects.filter(start_time__date=datetime.date(2016,9,25)
</code></pre>

<p>This gives me </p>

<pre><code>&lt;QuerySet [&lt;Task: 1st task&gt;, &lt;Task: 2nd task&gt;, &lt;Task: 3rd task&gt;, &lt;Task: 3rd task&gt;]&gt;
</code></pre>

<p>but when I change the date to 26 it gives me an empty set....</p>

<p>I even did this </p>

<pre><code>&gt;&gt;&gt; c= Task.objects.filter(start_time__date=datetime.datetime(2016,9,25,0,0,0,0,pytz.UTC)
</code></pre>

<p>got the same result.</p>

<p>So why is the date returning the entries from 26 as well....and on querring 26 it returns an empty set....</p>

<p>EDIT 1:
So i just figured out, the dates are stored with different times, I dont know why the template does not show the actual times. So in case of the above entries I checked the actual times and found the following...</p>

<pre><code>&gt;&gt;&gt; d= &lt;QuerySet [&lt;Task: 1st task&gt;, &lt;Task: 2nd task&gt;, &lt;Task: 3rd task&gt;, &lt;Task: 3rd task&gt;]&gt;
&gt;&gt;&gt; d[2].start_time
</code></pre>

<p>and got the following
datetime.datetime(2016, 9, 25, 19, 19, 59, 477000, tzinfo=)</p>

<p>which clearly shows that the 3rd task is stored at a different time and the one it is showing in the template, in fact I think it is exactly -5h from the time it is displaying which is GMT, so the real question now is why is template showing different time for the same model....and more importantly how can I correct it...</p>

<p>According to the <a href="https://docs.djangoproject.com/en/1.10/ref/models/querysets/#date" rel="nofollow">Django QuerySet reference for <code>date</code></a>:</p>

<blockquote>
  <p>When <code>USE_TZ</code> is True, fields are converted to the current time zone before filtering.</p>
</blockquote>

<p>Given that both the tasks occur shortly after midnight, I suspect that the conversion to your set timezone is causing the issue you are seeing.</p>

python django sqlite