Code

Ticket #10765: settings_folder_problem.diff

File settings_folder_problem.diff, 1.0 KB (added by vbmendes, 5 years ago)

Patch to fix the problem

Line 
1Index: django/utils/translation/trans_real.py
2===================================================================
3--- django/utils/translation/trans_real.py      (revisão 10369)
4+++ django/utils/translation/trans_real.py      (cópia de trabalho)
5@@ -127,7 +127,15 @@
6     if settings.SETTINGS_MODULE is not None:
7         parts = settings.SETTINGS_MODULE.split('.')
8         project = import_module(parts[0])
9-        projectpath = os.path.join(os.path.dirname(project.__file__), 'locale')
10+       
11+        # If the settings module is a folder,
12+        # the projectpath must be retrieved in a different way.
13+        # Maybe it's the case of adding a constant or a function
14+        # to get this info anywhere in django.
15+        if os.path.basename(project.__file__).startswith('__init__.py'):
16+            projectpath = os.path.join(os.path.dirname(os.path.dirname(project.__file__)), 'locale')
17+        else:
18+            projectpath = os.path.join(os.path.dirname(project.__file__), 'locale')
19     else:
20         projectpath = None
21