1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
--- python-django-1.2.3.orig/django/utils/formats.py
+++ python-django-1.2.3/django/utils/formats.py
@@ -7,6 +7,25 @@ from django.utils.importlib import impor
from django.utils.encoding import smart_str
from django.utils import dateformat, numberformat, datetime_safe
+
+FORMAT_SETTINGS = frozenset([
+ 'DECIMAL_SEPARATOR',
+ 'THOUSAND_SEPARATOR',
+ 'NUMBER_GROUPING',
+ 'FIRST_DAY_OF_WEEK',
+ 'MONTH_DAY_FORMAT',
+ 'TIME_FORMAT',
+ 'DATE_FORMAT',
+ 'DATETIME_FORMAT',
+ 'SHORT_DATE_FORMAT',
+ 'SHORT_DATETIME_FORMAT',
+ 'YEAR_MONTH_FORMAT',
+ 'DATE_INPUT_FORMATS',
+ 'TIME_INPUT_FORMATS',
+ 'DATETIME_INPUT_FORMATS',
+])
+
+
def get_format_modules(reverse=False):
"""
Returns an iterator over the format modules found in the project and Django
@@ -41,6 +60,8 @@ def get_format(format_type):
format_type is the name of the format, e.g. 'DATE_FORMAT'
"""
format_type = smart_str(format_type)
+ if format_type not in FORMAT_SETTINGS:
+ return format_type
if settings.USE_L10N:
for module in get_format_modules():
try:
--- python-django-1.2.3.orig/tests/regressiontests/i18n/tests.py
+++ python-django-1.2.3/tests/regressiontests/i18n/tests.py
@@ -421,6 +421,10 @@ class FormattingTests(TestCase):
finally:
deactivate()
+ def test_format_arbitrary_settings(self):
+ self.assertEqual(get_format('DEBUG'), 'DEBUG')
+
+
class MiscTests(TestCase):
def test_parse_spec_http_header(self):
|