mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
Fixed #14824 -- Corrected the handling of formats when USE_L10N is disabled. Thanks to nullie for the report and initial patch, and to idle for the separate report with helpful debug info.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15404 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -14,11 +14,21 @@ from django.utils.safestring import mark_safe
|
||||
_format_cache = {}
|
||||
_format_modules_cache = {}
|
||||
|
||||
def reset_format_cache():
|
||||
"""Clear any cached formats.
|
||||
|
||||
This method is provided primarily for testing purposes,
|
||||
so that the effects of cached formats can be removed.
|
||||
"""
|
||||
global _format_cache, _format_modules_cache
|
||||
_format_cache = {}
|
||||
_format_modules_cache = {}
|
||||
|
||||
def iter_format_modules(lang):
|
||||
"""
|
||||
Does the heavy lifting of finding format modules.
|
||||
"""
|
||||
if check_for_language(lang) or settings.USE_L10N:
|
||||
if check_for_language(lang):
|
||||
format_locations = ['django.conf.locale.%s']
|
||||
if settings.FORMAT_MODULE_PATH:
|
||||
format_locations.append(settings.FORMAT_MODULE_PATH + '.%s')
|
||||
|
||||
@@ -7,7 +7,7 @@ from django.utils import importlib
|
||||
from django.utils.translation import check_for_language, activate, to_locale, get_language
|
||||
from django.utils.text import javascript_quote
|
||||
from django.utils.encoding import smart_unicode
|
||||
from django.utils.formats import get_format_modules
|
||||
from django.utils.formats import get_format_modules, get_format
|
||||
|
||||
def set_language(request):
|
||||
"""
|
||||
@@ -49,10 +49,7 @@ def get_formats():
|
||||
result = {}
|
||||
for module in [settings] + get_format_modules(reverse=True):
|
||||
for attr in FORMAT_SETTINGS:
|
||||
try:
|
||||
result[attr] = getattr(module, attr)
|
||||
except AttributeError:
|
||||
pass
|
||||
result[attr] = get_format(attr)
|
||||
src = []
|
||||
for k, v in result.items():
|
||||
if isinstance(v, (basestring, int)):
|
||||
|
||||
Reference in New Issue
Block a user