Removed USE_L10N setting from Django 4.0.

USE_L10N defaults to True from Django 4.0, and will be removed in Django 5.0.
This commit is contained in:
Carlton Gibson 2021-09-22 10:02:28 +02:00
parent 2d9eee5d02
commit 4916854492
2 changed files with 5 additions and 3 deletions

View File

@ -18,6 +18,8 @@ def pytest_addoption(parser):
def pytest_configure(config): def pytest_configure(config):
from django.conf import settings from django.conf import settings
# USE_L10N is deprecated, and will be removed in Django 5.0.
use_l10n = {"USE_L10N": True} if django.VERSION < (4, 0) else {}
settings.configure( settings.configure(
DEBUG_PROPAGATE_EXCEPTIONS=True, DEBUG_PROPAGATE_EXCEPTIONS=True,
DATABASES={ DATABASES={
@ -33,7 +35,6 @@ def pytest_configure(config):
SITE_ID=1, SITE_ID=1,
SECRET_KEY='not very secret in tests', SECRET_KEY='not very secret in tests',
USE_I18N=True, USE_I18N=True,
USE_L10N=True,
STATIC_URL='/static/', STATIC_URL='/static/',
ROOT_URLCONF='tests.urls', ROOT_URLCONF='tests.urls',
TEMPLATES=[ TEMPLATES=[
@ -68,6 +69,7 @@ def pytest_configure(config):
PASSWORD_HASHERS=( PASSWORD_HASHERS=(
'django.contrib.auth.hashers.MD5PasswordHasher', 'django.contrib.auth.hashers.MD5PasswordHasher',
), ),
**use_l10n,
) )
# guardian is optional # guardian is optional

View File

@ -1220,12 +1220,12 @@ class TestNoStringCoercionDecimalField(FieldValues):
class TestLocalizedDecimalField(TestCase): class TestLocalizedDecimalField(TestCase):
@override_settings(USE_L10N=True, LANGUAGE_CODE='pl') @override_settings(LANGUAGE_CODE='pl')
def test_to_internal_value(self): def test_to_internal_value(self):
field = serializers.DecimalField(max_digits=2, decimal_places=1, localize=True) field = serializers.DecimalField(max_digits=2, decimal_places=1, localize=True)
assert field.to_internal_value('1,1') == Decimal('1.1') assert field.to_internal_value('1,1') == Decimal('1.1')
@override_settings(USE_L10N=True, LANGUAGE_CODE='pl') @override_settings(LANGUAGE_CODE='pl')
def test_to_representation(self): def test_to_representation(self):
field = serializers.DecimalField(max_digits=2, decimal_places=1, localize=True) field = serializers.DecimalField(max_digits=2, decimal_places=1, localize=True)
assert field.to_representation(Decimal('1.1')) == '1,1' assert field.to_representation(Decimal('1.1')) == '1,1'