The generic archive_month view has had some problems in the past with
"off-by-one"-style errors; see, for example, #992, nostalgic for me
because it was the first patch of mine ever accepted into Django.
Unfortunately, the view now includes too *much* instead of too little,
as mentioned in #3031, which hasn't really gone anywhere.
To see an example of the problem, consider this simplified model:
class Story(models.Model):
title = models.CharField(max_length=250)
pub_date = models.DateTimeField()
body = models.TextField()
If we have a Story with a pub_date of 2007-08-01 00:00:00, it will
show up in both the July and August archive_month views.
The reason for this is that the generic view does a "range" lookup,
and that becomes a BETWEEN in the SQL, using two dates: the first day
of the month and the first day of the next month.
I'm going to have to patch this for the buggy install that's
displaying this behavior (site with a workflow that typically sets
lots of things to be published at 00:00:00), but I'd like to get it
fixed upstream in Django as well; I'm just not certain of the best way
to go about it. Two options occur to me:
1. Change the lookup type, to do a 'gte' on the first day of the month
and an 'lt' on the first day of the next month.
2. Keep the lookup type, but switch the internals of the view to using
datetime.datetime objects instead of datetime.date, so that the
"last_day" variable can have one second subtracted from it and roll
back to 23:59:59 on the true last day of the month. Backwards
compatibility with the expectation of a datetime.date in the context
would be relatively easy.
Does anyone have a strong opinion one way or another?
--
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---