diff --git a/django/contrib/admindocs/views.py b/django/contrib/admindocs/views.py index e154c9299a..5bfa0f7184 100644 --- a/django/contrib/admindocs/views.py +++ b/django/contrib/admindocs/views.py @@ -54,7 +54,9 @@ def template_tag_index(request): load_all_installed_template_libraries() tags = [] - for module_name, library in template.libraries.items(): + app_libs = template.libraries.items() + builtin_libs = [(None, lib) for lib in template.builtins] + for module_name, library in builtin_libs + app_libs: for tag_name, tag_func in library.tags.items(): title, body, metadata = utils.parse_docstring(tag_func.__doc__) if title: @@ -87,7 +89,9 @@ def template_filter_index(request): load_all_installed_template_libraries() filters = [] - for module_name, library in template.libraries.items(): + app_libs = template.libraries.items() + builtin_libs = [(None, lib) for lib in template.builtins] + for module_name, library in builtin_libs + app_libs: for filter_name, filter_func in library.filters.items(): title, body, metadata = utils.parse_docstring(filter_func.__doc__) if title: diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py index 41aade0561..bb787be638 100644 --- a/tests/regressiontests/admin_views/tests.py +++ b/tests/regressiontests/admin_views/tests.py @@ -2170,3 +2170,40 @@ class UserAdminTest(TestCase): self.assertRedirects(response, '/test_admin/admin/auth/user/add/') self.assertEquals(User.objects.count(), user_count + 1) self.assertNotEquals(new_user.password, UNUSABLE_PASSWORD) + +class AdminDocsTest(TestCase): + fixtures = ['admin-views-users.xml'] + + def setUp(self): + self.client.login(username='super', password='secret') + + def tearDown(self): + self.client.logout() + + def test_tags(self): + response = self.client.get('/test_admin/admin/doc/tags/') + + # The builtin tag group exists + self.assertContains(response, "

Built-in tags

", count=2) + + # A builtin tag exists in both the index and detail + self.assertContains(response, '

autoescape

') + self.assertContains(response, '
  • autoescape
  • ') + + # An app tag exists in both the index and detail + # The builtin tag group exists + self.assertContains(response, "

    admin_list

    ", count=2) + + # A builtin tag exists in both the index and detail + self.assertContains(response, '

    autoescape

    ') + self.assertContains(response, '
  • admin_actions
  • ') + + def test_filters(self): + response = self.client.get('/test_admin/admin/doc/filters/') + + # The builtin filter group exists + self.assertContains(response, "

    Built-in filters

    ", count=2) + + # A builtin filter exists in both the index and detail + self.assertContains(response, '

    add

    ') + self.assertContains(response, '
  • add
  • ') diff --git a/tests/runtests.py b/tests/runtests.py index 4d7c55bae0..83f141d3d2 100755 --- a/tests/runtests.py +++ b/tests/runtests.py @@ -27,6 +27,7 @@ ALWAYS_INSTALLED_APPS = [ 'django.contrib.messages', 'django.contrib.comments', 'django.contrib.admin', + 'django.contrib.admindocs', ] def get_test_models():