Ticket #16038: form-field-patch.patch

File form-field-patch.patch, 1.1 KB (added by jonathanslenders, 4 years ago)

patch for forms.Field

  • django/forms/fields.py

     
    1515except ImportError:
    1616    from StringIO import StringIO
    1717
     18from django.conf import settings
    1819from django.core.exceptions import ValidationError
    1920from django.core import validators
    2021from django.utils import formats
     
    5657
    5758    def __init__(self, required=True, widget=None, label=None, initial=None,
    5859                 help_text=None, error_messages=None, show_hidden_initial=False,
    59                  validators=[], localize=False):
     60                 validators=[], localize=None):
    6061        # required -- Boolean that specifies whether the field is required.
    6162        #             True by default.
    6263        # widget -- A Widget class, or instance of a Widget class, that should
     
    8990            widget = widget()
    9091
    9192        # Trigger the localization machinery if needed.
    92         self.localize = localize
     93        if localize is not None:
     94            self.localize = localize
     95        else:
     96            self.localize = getattr(settings, 'USE_L10N', False)
    9397        if self.localize:
    9498            widget.is_localized = True
Back to Top