From 01ab84c61330ffa5ac87c637249611c5e5343e57 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Mon, 22 Dec 2014 15:13:47 -0500 Subject: [PATCH] Fixed #23525 -- Fixed admindocs crash on apps installed as eggs. Thanks welbornprod for report and initial patch. --- django/contrib/admindocs/views.py | 17 +++++++++++------ docs/releases/1.7.2.txt | 2 ++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/django/contrib/admindocs/views.py b/django/contrib/admindocs/views.py index 1768fd72c91..bf706d03072 100644 --- a/django/contrib/admindocs/views.py +++ b/django/contrib/admindocs/views.py @@ -315,6 +315,10 @@ def load_all_installed_template_libraries(): # Load/register all template tag libraries from installed apps. for module_name in template.get_templatetags_modules(): mod = import_module(module_name) + if not hasattr(mod, '__file__'): + # e.g. packages installed as eggs + continue + try: libraries = [ os.path.splitext(p)[0] @@ -322,12 +326,13 @@ def load_all_installed_template_libraries(): if p.endswith('.py') and p[0].isalpha() ] except OSError: - libraries = [] - for library_name in libraries: - try: - template.get_library(library_name) - except template.InvalidTemplateLibrary: - pass + continue + else: + for library_name in libraries: + try: + template.get_library(library_name) + except template.InvalidTemplateLibrary: + pass def get_return_data_type(func_name): diff --git a/docs/releases/1.7.2.txt b/docs/releases/1.7.2.txt index ef65a37963c..179bd5f7db4 100644 --- a/docs/releases/1.7.2.txt +++ b/docs/releases/1.7.2.txt @@ -160,3 +160,5 @@ Bugfixes a crash when the index name requires it (:ticket:`#24015`). * Added ``datetime.time`` support to migrations questioner (:ticket:`23998`). + +* Fixed admindocs crash on apps installed as eggs (:ticket:`23525`).