diff --git a/django/contrib/admin/templatetags/admin_list.py b/django/contrib/admin/templatetags/admin_list.py
index db58af9..806be24 100644
a
|
b
|
def date_hierarchy(cl):
|
261 | 261 | 'show': True, |
262 | 262 | 'back': { |
263 | 263 | 'link': link({year_field: year_lookup}), |
264 | | 'title': year_lookup |
| 264 | 'title': str(year_lookup) |
265 | 265 | }, |
266 | 266 | 'choices': [{ |
267 | 267 | 'link': link({year_field: year_lookup, month_field: month_lookup, day_field: day.day}), |
diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py
index f392393..53a2c73 100644
a
|
b
|
class DateHierarchyTests(TestCase):
|
2588 | 2588 | def setUp(self): |
2589 | 2589 | self.client.login(username='super', password='secret') |
2590 | 2590 | |
| 2591 | def assert_non_localized_year(self, url, year): |
| 2592 | """ Refs #15234. Ensure that the year is not localized with |
| 2593 | USE_THOUSAND_SEPARATOR. |
| 2594 | """ |
| 2595 | self.old_USE_THOUSAND_SEPARATOR = settings.USE_THOUSAND_SEPARATOR |
| 2596 | self.old_USE_L10N = settings.USE_L10N |
| 2597 | settings.USE_THOUSAND_SEPARATOR = True |
| 2598 | settings.USE_L10N = True |
| 2599 | response = self.client.get(url) |
| 2600 | self.assertNotContains(response, formats.number_format(year)) |
| 2601 | settings.USE_THOUSAND_SEPARATOR = self.old_USE_THOUSAND_SEPARATOR |
| 2602 | settings.USE_L10N = self.old_USE_L10N |
| 2603 | |
2591 | 2604 | def assert_contains_year_link(self, response, date): |
2592 | 2605 | self.assertContains(response, '?release_date__year=%d"' % (date.year,)) |
2593 | 2606 | |
… |
… |
class DateHierarchyTests(TestCase):
|
2618 | 2631 | """ |
2619 | 2632 | DATE = datetime.date(2000, 6, 30) |
2620 | 2633 | Podcast.objects.create(release_date=DATE) |
2621 | | response = self.client.get( |
2622 | | reverse('admin:admin_views_podcast_changelist')) |
| 2634 | url = reverse('admin:admin_views_podcast_changelist') |
| 2635 | response = self.client.get(url) |
2623 | 2636 | self.assert_contains_day_link(response, DATE) |
| 2637 | self.assert_non_localized_year(url, 2000) |
2624 | 2638 | |
2625 | 2639 | def test_within_month(self): |
2626 | 2640 | """ |
… |
… |
class DateHierarchyTests(TestCase):
|
2631 | 2645 | datetime.date(2000, 6, 3)) |
2632 | 2646 | for date in DATES: |
2633 | 2647 | Podcast.objects.create(release_date=date) |
2634 | | response = self.client.get( |
2635 | | reverse('admin:admin_views_podcast_changelist')) |
| 2648 | url = reverse('admin:admin_views_podcast_changelist') |
| 2649 | response = self.client.get(url) |
2636 | 2650 | for date in DATES: |
2637 | 2651 | self.assert_contains_day_link(response, date) |
| 2652 | self.assert_non_localized_year(url, 2000) |
2638 | 2653 | |
2639 | 2654 | def test_within_year(self): |
2640 | 2655 | """ |
… |
… |
class DateHierarchyTests(TestCase):
|
2645 | 2660 | datetime.date(2000, 5, 3)) |
2646 | 2661 | for date in DATES: |
2647 | 2662 | Podcast.objects.create(release_date=date) |
2648 | | response = self.client.get( |
2649 | | reverse('admin:admin_views_podcast_changelist')) |
| 2663 | url = reverse('admin:admin_views_podcast_changelist') |
| 2664 | response = self.client.get(url) |
2650 | 2665 | # no day-level links |
2651 | 2666 | self.assertNotContains(response, 'release_date__day=') |
2652 | 2667 | for date in DATES: |
2653 | 2668 | self.assert_contains_month_link(response, date) |
| 2669 | self.assert_non_localized_year(url, 2000) |
2654 | 2670 | |
2655 | 2671 | def test_multiple_years(self): |
2656 | 2672 | """ |
… |
… |
class DateHierarchyTests(TestCase):
|
2671 | 2687 | |
2672 | 2688 | # and make sure GET parameters still behave correctly |
2673 | 2689 | for date in DATES: |
2674 | | response = self.client.get( |
2675 | | '%s?release_date__year=%d' % ( |
2676 | | reverse('admin:admin_views_podcast_changelist'), |
2677 | | date.year)) |
| 2690 | url = '%s?release_date__year=%d' % ( |
| 2691 | reverse('admin:admin_views_podcast_changelist'), |
| 2692 | date.year) |
| 2693 | response = self.client.get(url) |
2678 | 2694 | self.assert_contains_month_link(response, date) |
2679 | | |
2680 | | response = self.client.get( |
2681 | | '%s?release_date__year=%d&release_date__month=%d' % ( |
2682 | | reverse('admin:admin_views_podcast_changelist'), |
2683 | | date.year, date.month)) |
| 2695 | self.assert_non_localized_year(url, 2000) |
| 2696 | self.assert_non_localized_year(url, 2003) |
| 2697 | self.assert_non_localized_year(url, 2005) |
| 2698 | |
| 2699 | url = '%s?release_date__year=%d&release_date__month=%d' % ( |
| 2700 | reverse('admin:admin_views_podcast_changelist'), |
| 2701 | date.year, date.month) |
| 2702 | response = self.client.get(url) |
2684 | 2703 | self.assert_contains_day_link(response, date) |
| 2704 | self.assert_non_localized_year(url, 2000) |
| 2705 | self.assert_non_localized_year(url, 2003) |
| 2706 | self.assert_non_localized_year(url, 2005) |