diff --git a/AUTHORS b/AUTHORS
index c173a20..83b56af 100644
|
a
|
b
|
answer newbie questions, and generally made Django that much better:
|
| 247 | 247 | Christopher Lenz <http://www.cmlenz.net/> |
| 248 | 248 | lerouxb@gmail.com |
| 249 | 249 | Piotr Lewandowski <piotr.lewandowski@gmail.com> |
| | 250 | Justin Lilly <justinlilly@gmail.com> |
| 250 | 251 | Waylan Limberg <waylan@gmail.com> |
| 251 | 252 | limodou |
| 252 | 253 | Philip Lindborg <philip.lindborg@gmail.com> |
diff --git a/django/views/generic/date_based.py b/django/views/generic/date_based.py
index c5f1748..9150266 100644
|
a
|
b
|
def archive_month(request, year, month, queryset, date_field,
|
| 116 | 116 | """ |
| 117 | 117 | if extra_context is None: extra_context = {} |
| 118 | 118 | try: |
| 119 | | date = datetime.date(*time.strptime(year+month, '%Y'+month_format)[:3]) |
| | 119 | date = datetime.date(*time.strptime("%s-%s" % (year, month), '%s-%s' % ('%Y', month_format))[:3]) |
| 120 | 120 | except ValueError: |
| 121 | 121 | raise Http404 |
| 122 | 122 | |
| … |
… |
def archive_day(request, year, month, day, queryset, date_field,
|
| 237 | 237 | """ |
| 238 | 238 | if extra_context is None: extra_context = {} |
| 239 | 239 | try: |
| 240 | | date = datetime.date(*time.strptime(year+month+day, '%Y'+month_format+day_format)[:3]) |
| | 240 | date = datetime.date(*time.strptime("%s-%s-%s" % (year, month, day), '%s-%s-%s' % ('%Y', month_format, day_format))[:3]) |
| 241 | 241 | except ValueError: |
| 242 | 242 | raise Http404 |
| 243 | 243 | |
| … |
… |
def object_detail(request, year, month, day, queryset, date_field,
|
| 307 | 307 | """ |
| 308 | 308 | if extra_context is None: extra_context = {} |
| 309 | 309 | try: |
| 310 | | date = datetime.date(*time.strptime(year+month+day, '%Y'+month_format+day_format)[:3]) |
| | 310 | date = datetime.date(*time.strptime('%s-%s-%s' % (year, month, day), '%s-%s-%s' % ('%Y', month_format, day_format))[:3]) |
| 311 | 311 | except ValueError: |
| 312 | 312 | raise Http404 |
| 313 | 313 | |
diff --git a/tests/regressiontests/views/tests/generic/date_based.py b/tests/regressiontests/views/tests/generic/date_based.py
index 3cb7e1e..abbbba9 100644
|
a
|
b
|
class MonthArchiveTest(TestCase):
|
| 90 | 90 | response = self.client.get('/views/date_based/datefield/archive_month/2004/02/') |
| 91 | 91 | self.assertEqual(response.status_code, 404) |
| 92 | 92 | |
| | 93 | class DayMonthYearArchiveTest(TestCase): |
| | 94 | " Fixes #7944 - Generic date based views get confused with numeric month format" |
| | 95 | def setUp(self): |
| | 96 | author = Author(name="John Smith") |
| | 97 | author.save() |
| | 98 | |
| | 99 | jan_double_day = datetime(2004, 1, 21, 0, 0, 1) |
| | 100 | |
| | 101 | article = Article(title="example", author=author) |
| | 102 | |
| | 103 | article.date_created = jan_double_day |
| | 104 | article.save() |
| | 105 | |
| | 106 | def tests_first_month(self): |
| | 107 | foo = Article.objects.filter(date_created__year=2004, date_created__month=1, date_created__day=21) |
| | 108 | self.assertEqual(len(foo), 1) |
| | 109 | |
| | 110 | response = self.client.get('/views/date_based/archive_day/2004/1/21/') |
| | 111 | self.assertEqual(response.status_code, 200) |
diff --git a/tests/regressiontests/views/urls.py b/tests/regressiontests/views/urls.py
index 6403ab3..a6283c1 100644
|
a
|
b
|
date_based_info_dict = {
|
| 20 | 20 | 'date_field': 'date_created', |
| 21 | 21 | 'month_format': '%m', |
| 22 | 22 | } |
| | 23 | numeric_days_info_dict = dict(date_based_info_dict, day_format='%d') |
| | 24 | |
| 23 | 25 | date_based_datefield_info_dict = dict(date_based_info_dict, queryset=DateArticle.objects.all()) |
| 24 | 26 | |
| 25 | 27 | urlpatterns = patterns('', |
| … |
… |
urlpatterns += patterns('django.views.generic.date_based',
|
| 46 | 48 | (r'^date_based/object_detail/(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/(?P<slug>[-\w]+)/allow_future/$', |
| 47 | 49 | 'object_detail', |
| 48 | 50 | dict(allow_future=True, slug_field='slug', **date_based_info_dict)), |
| | 51 | (r'^date_based/archive_day/(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/$', |
| | 52 | 'archive_day', |
| | 53 | numeric_days_info_dict), |
| 49 | 54 | (r'^date_based/archive_month/(?P<year>\d{4})/(?P<month>\d{1,2})/$', |
| 50 | 55 | 'archive_month', |
| 51 | 56 | date_based_info_dict), |
diff --git a/tests/templates/views/article_archive_day.html b/tests/templates/views/article_archive_day.html
new file mode 100644
index 0000000..bd2d67f
|
-
|
+
|
|
| | 1 | This template intentionally left blank |