Ticket #13621: ticket13621-alternative3-tested.diff

File ticket13621-alternative3-tested.diff, 1.5 KB (added by jacmkno, 5 years ago)

An alternative patch, makes the localize attribute default to True in date/time fields

  • django/forms/fields.py

     
    323323    }
    324324
    325325    def __init__(self, input_formats=None, *args, **kwargs):
     326        kwargs['localize'] = kwargs.get('localize', True) # Default localize to True in date / time fields
    326327        super(DateField, self).__init__(*args, **kwargs)
    327328        self.input_formats = input_formats
    328329
     
    351352    }
    352353
    353354    def __init__(self, input_formats=None, *args, **kwargs):
     355        kwargs['localize'] = kwargs.get('localize', True) # Default localize to True in date / time fields
    354356        super(TimeField, self).__init__(*args, **kwargs)
    355357        self.input_formats = input_formats
    356358
     
    377379    }
    378380
    379381    def __init__(self, input_formats=None, *args, **kwargs):
     382        kwargs['localize'] = kwargs.get('localize', True) # Default localize to True in date / time fields
    380383        super(DateTimeField, self).__init__(*args, **kwargs)
    381384        self.input_formats = input_formats
    382385
     
    842845        errors = self.default_error_messages.copy()
    843846        if 'error_messages' in kwargs:
    844847            errors.update(kwargs['error_messages'])
     848        kwargs['localize'] = kwargs.get('localize', True) # Default localize to True in date / time fields
    845849        localize = kwargs.get('localize', False)
    846850        fields = (
    847851            DateField(input_formats=input_date_formats,
Back to Top