mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #19963 -- Added support for date_hierarchy across relations.
This commit is contained in:
committed by
Tim Graham
parent
89ca112884
commit
2f9c4e2b6f
@@ -5331,6 +5331,26 @@ class DateHierarchyTests(TestCase):
|
||||
self.assert_non_localized_year(response, 2003)
|
||||
self.assert_non_localized_year(response, 2005)
|
||||
|
||||
def test_related_field(self):
|
||||
questions_data = (
|
||||
# (posted data, number of answers),
|
||||
(datetime.date(2001, 1, 30), 0),
|
||||
(datetime.date(2003, 3, 15), 1),
|
||||
(datetime.date(2005, 5, 3), 2),
|
||||
)
|
||||
for date, answer_count in questions_data:
|
||||
question = Question.objects.create(posted=date)
|
||||
for i in range(answer_count):
|
||||
question.answer_set.create()
|
||||
|
||||
response = self.client.get(reverse('admin:admin_views_answer_changelist'))
|
||||
for date, answer_count in questions_data:
|
||||
link = '?question__posted__year=%d"' % (date.year,)
|
||||
if answer_count > 0:
|
||||
self.assertContains(response, link)
|
||||
else:
|
||||
self.assertNotContains(response, link)
|
||||
|
||||
|
||||
@override_settings(ROOT_URLCONF='admin_views.urls')
|
||||
class AdminCustomSaveRelatedTests(TestCase):
|
||||
|
||||
Reference in New Issue
Block a user