﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
16443	previous_day from views.generic.dates.DayArchiveView doesn't return the previous day	Bernhard Essl	nobody	"The '''previous_day''' from views.generic.dates.DayArchiveView returns not the previous day instead the day before the previous day (24 June -> 22 June).

{{{
# blog/models.py
from django.db import models

class Post(models.Model):
    title = models.TextField()
    pub_date = models.DateTimeField()

    def __unicode__(self):
        return u""%s"" % (self.pub_date,)

# url.py
from django.conf.urls.defaults import patterns, include, url
from django.views.generic import dates
from django.views import generic
from blog.models import Post
    
class PostDayArchive(generic.DayArchiveView):
    queryset = Post.objects.all()
    date_field = 'pub_date'

urlpatterns = patterns('',
    url(r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\d{1,2})/$', PostDayArchive.as_view()),
)

# templates/blog/post_archive_day.html
{{ previous_day }}

# 4 objects post from june 21-24
Post.objects.all()
[<Post: 2011-06-24 12:33:10>, <Post: 2011-06-23 13:33:10>, <Post: 2011-06-22 13:33:10>, <Post: 2011-06-21 13:33:10>]

# page request
$ curl http://127.0.0.1:8000/2011/jun/24/
June 22, 2011
}}}


When I open the page with the URL ''/2011/jun/24/'' I get ''""June 22, 2011""'' for the ""previous_day""; on ''/2011/jun/23/'' I get ''""June 21, 2011""'' and on ''/2011/jun/22/'' I get None.

Some notes:

- On production sometimes previous_day is working correctly. Didn't find a pattern. :(
- I use Django trunk (16527)
- The code works fine with models.DateField() instead of models.DateTimeField()
- I tested with MySQL and SQLite
- all other template tags like ''next_day'' or ''today'' are working"	Bug	closed	Generic views	dev	Normal	fixed			Accepted	0	0	0	0	0	0
