Skip to content
Browse files

Moved a settings usage up the stack in utils/ #unsettings

  • Loading branch information...
1 parent 0b7cf56 commit e844e10b4f06c13d24d405fe0d2e80a23d260508 @adrianholovaty adrianholovaty committed
Showing with 6 additions and 7 deletions.
  1. +4 −4 django/utils/
  2. +2 −3 tests/i18n/
8 django/utils/
@@ -40,14 +40,14 @@ def reset_format_cache():
_format_cache = {}
_format_modules_cache = {}
-def iter_format_modules(lang):
+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 settings.FORMAT_MODULE_PATH:
- format_locations.append(settings.FORMAT_MODULE_PATH + '.%s')
+ if format_module_path:
+ format_locations.append(format_module_path + '.%s')
locale = to_locale(lang)
locales = [locale]
@@ -66,7 +66,7 @@ def get_format_modules(lang=None, reverse=False):
if lang is None:
lang = get_language()
- modules = _format_modules_cache.setdefault(lang, list(iter_format_modules(lang)))
+ modules = _format_modules_cache.setdefault(lang, list(iter_format_modules(lang, settings.FORMAT_MODULE_PATH)))
if reverse:
return list(reversed(modules))
return modules
5 tests/i18n/
@@ -728,9 +728,8 @@ def test_iter_format_modules(self):
with translation.override('de-at', deactivate=True):
de_format_mod = import_module('')
self.assertEqual(list(iter_format_modules('de')), [de_format_mod])
- with self.settings(FORMAT_MODULE_PATH='i18n.other.locale'):
- test_de_format_mod = import_module('')
- self.assertEqual(list(iter_format_modules('de')), [test_de_format_mod, de_format_mod])
+ test_de_format_mod = import_module('')
+ self.assertEqual(list(iter_format_modules('de', 'i18n.other.locale')), [test_de_format_mod, de_format_mod])
def test_iter_format_modules_stability(self):

2 comments on commit e844e10

Django member

This is the first commit in the "unsettings" project, where we refactor the usage of settings to encourage use of Django as a library rather than a framework. Much more to come. Discussed at DjangoCon sprint in Chicago.

Django member

@adrianholovaty Can we have some discussions of that on the ML before we start with something like this (eg what to tackle how etc…)? Also personally, I'd prefer reviewable pull requests which takle a bit more than small stuff like this, makes it hard to see the bigger picture… Thank you.

Please sign in to comment.
Something went wrong with that request. Please try again.