#17192 closed Bug (fixed)
next_day from views.generic.dates.DayArchiveView returns None instead of today
Reported by: | Owned by: | Aymeric Augustin | |
---|---|---|---|
Component: | Generic views | Version: | 1.3 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The next_day from views.generic.dates.DayArchiveView returns None when next_day would be today.
# in models.py from django.db import models class Post(models.Model): pub_date = models.DateTimeField(auto_now_add=True) # views.py from django.views import generic from bugdemo.models import * class PostDayView(generic.DayArchiveView): queryset = Post.objects.all() date_field = 'pub_date' allow_empty = True allow_future = False # urls.py from django.conf.urls.defaults import patterns, include, url from bugdemo.views import PostDayView urlpatterns = patterns('', (r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\d{1,2})/$', PostDayView.as_view()), ) # post_archive_day.html Previous day: {{ previous_day }} Next day: {{ next_day }} # page request $ curl http://localhost:8000/2011/nov/9/ # that's yesterday, as of the time of writing Previous day: Nov. 8, 2011 Next day: None
Unless I misunderstand what the behavior is supposed to be, I expected the next_day
to be datetime.date(2011, 11, 9)
, not None.
Attachments (1)
Change History (8)
comment:1 by , 13 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 13 years ago
The problem appears to be in the old-style generic view too: https://code.djangoproject.com/browser/django/trunk/django/views/generic/date_based.py?rev=15989#L283
Even though it is deprecated, it is still supported and so it should be fixed as well.
comment:3 by , 13 years ago
Owner: | changed from | to
---|
by , 13 years ago
Attachment: | next_day_17192.diff added |
---|
comment:4 by , 13 years ago
I've done some tests and it appears that in elder generic views this particular bug is not present, although it certainly is for the new-style generic views.
I've included patch for it.
comment:5 by , 13 years ago
Owner: | changed from | to
---|
comment:6 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
This was fixed as a side effect of the rewrite in 20e697368219603599649bc67aea5e087caedeae.
I'm going to add a regression test anyway.
Looking at the code, the bug is most likely here: https://code.djangoproject.com/browser/django/trunk/django/views/generic/dates.py?rev=16974#L586
The condition should be a "less than or equal".