summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorMartin Brochhaus <mbrochh@gmail.com>2014-05-19 13:23:45 +0800
committerTim Graham <timograham@gmail.com>2014-05-19 07:59:13 -0400
commit950b6de16ac2f8135612f2ed5984c090dd8e4dcf (patch)
tree111743c752fd84867fb8f77af2c04675a6df8a3d /django
parentbfac6bef833d2520853c88188560b81bc7e3988d (diff)
Fixed #20477: Allowed settings.FORMAT_MODULE_PATH to be a list of modules.
Previously the FORMAT_MODULE_PATH setting only accepted one string (dotted module path). This is useful when using several reusable third party apps that define new formats. We can now use them all and we can even override some of the formats by providing a project-wide format module.
Diffstat (limited to 'django')
-rw-r--r--django/utils/formats.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/django/utils/formats.py b/django/utils/formats.py
index fc68179f3a..5bb8d75df7 100644
--- a/django/utils/formats.py
+++ b/django/utils/formats.py
@@ -47,10 +47,15 @@ def iter_format_modules(lang, format_module_path=None):
Does the heavy lifting of finding format modules.
"""
if check_for_language(lang):
- format_locations = ['django.conf.locale.%s']
- if format_module_path:
- format_locations.append(format_module_path + '.%s')
- format_locations.reverse()
+ format_locations = []
+ if settings.FORMAT_MODULE_PATH:
+ if isinstance(settings.FORMAT_MODULE_PATH, six.string_types):
+ format_module_path_setting = [settings.FORMAT_MODULE_PATH]
+ else:
+ format_module_path_setting = settings.FORMAT_MODULE_PATH
+ for path in format_module_path_setting:
+ format_locations.append(path + '.%s')
+ format_locations.append('django.conf.locale.%s')
locale = to_locale(lang)
locales = [locale]
if '_' in locale: