diff --git a/django/template/loaders/app_directories.py b/django/template/loaders/app_directories.py index 6e0f079de7..887f8a0b72 100644 --- a/django/template/loaders/app_directories.py +++ b/django/template/loaders/app_directories.py @@ -12,9 +12,11 @@ from django.template.base import TemplateDoesNotExist from django.template.loader import BaseLoader from django.utils._os import safe_join from django.utils.importlib import import_module +from django.utils import six # At compile time, cache the directories to search. -fs_encoding = sys.getfilesystemencoding() or sys.getdefaultencoding() +if not six.PY3: + fs_encoding = sys.getfilesystemencoding() or sys.getdefaultencoding() app_template_dirs = [] for app in settings.INSTALLED_APPS: try: @@ -23,7 +25,9 @@ for app in settings.INSTALLED_APPS: raise ImproperlyConfigured('ImportError %s: %s' % (app, e.args[0])) template_dir = os.path.join(os.path.dirname(mod.__file__), 'templates') if os.path.isdir(template_dir): - app_template_dirs.append(template_dir.decode(fs_encoding)) + if not six.PY3: + template_dir = template_dir.decode(fs_encoding) + app_template_dirs.append(template_dir) # It won't change, so convert it to a tuple to save memory. app_template_dirs = tuple(app_template_dirs)