From d4733b6df07b1f8a869eed8eac86869d1d14472c Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Thu, 19 Dec 2013 20:32:00 +0100 Subject: [PATCH] Not all Python modules have a __path__. --- django/core/apps/base.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/django/core/apps/base.py b/django/core/apps/base.py index 83c073a12a..2503d9e3ff 100644 --- a/django/core/apps/base.py +++ b/django/core/apps/base.py @@ -35,9 +35,13 @@ class AppConfig(object): self.models = None # Filesystem path to the application directory eg. - # u'/usr/lib/python2.7/dist-packages/django/contrib/admin'. - # This is a unicode object on Python 2 and a str on Python 3. - self.path = upath(self.app_module.__path__[0]) + # u'/usr/lib/python2.7/dist-packages/django/contrib/admin'. May be + # None if the application isn't a bona fide package eg. if it's an + # egg. Otherwise it's a unicode on Python 2 and a str on Python 3. + try: + self.path = upath(self.app_module.__path__[0]) + except AttributeError: + self.path = None def __repr__(self): return '' % self.label