Ticket #15084: django_no-app-import.diff

File django_no-app-import.diff, 893 bytes (added by jeff@…, 5 years ago)

Suggested, untested fix

  • django/utils/translation/trans_real.py

    diff --git a/django/utils/translation/trans_real.py b/django/utils/translation/trans_real.py
    index a5c612b..c7b5873 100644
    a b import sys 
    77import warnings
    88import gettext as gettext_module
    99from cStringIO import StringIO
     10import pkgutil
    1011
    1112from django.utils.importlib import import_module
    1213from django.utils.safestring import mark_safe, SafeData
    def translation(language): 
    163164                res = _merge(localepath)
    164165
    165166        for appname in settings.INSTALLED_APPS:
    166             app = import_module(appname)
    167             apppath = os.path.join(os.path.dirname(app.__file__), 'locale')
     167            app = pkgutil.get_loader("app")
     168            apppath = os.path.join(app.filename, 'locale')
    168169
    169170            if os.path.isdir(apppath):
    170171                res = _merge(apppath)
Back to Top