Ticket #3959: label.diff

File label.diff, 2.7 KB (added by Marty Alchin <gulopine@…>, 8 years ago)

Simply moves label to the front of the argument list for fields

  • fields.py

     
    3636    # Tracks each time a Field instance is created. Used to retain order.
    3737    creation_counter = 0
    3838
    39     def __init__(self, required=True, widget=None, label=None, initial=None, help_text=None):
     39    def __init__(self, label=None, required=True, widget=None, initial=None, help_text=None):
     40        # label -- A verbose name for this field, for use in displaying this
     41        #          field in a form. By default, Django will use a "pretty"
     42        #          version of the form field name, if the Field is part of a
     43        #          Form.
    4044        # required -- Boolean that specifies whether the field is required.
    4145        #             True by default.
    4246        # widget -- A Widget class, or instance of a Widget class, that should
    4347        #           be used for this Field when displaying it. Each Field has a
    4448        #           default Widget that it'll use if you don't specify this. In
    4549        #           most cases, the default widget is TextInput.
    46         # label -- A verbose name for this field, for use in displaying this
    47         #          field in a form. By default, Django will use a "pretty"
    48         #          version of the form field name, if the Field is part of a
    49         #          Form.
    5050        # initial -- A value to use in this Field's initial display. This value
    5151        #            is *not* used as a fallback if data isn't given.
    5252        # help_text -- An optional string to use as "help text" for this Field.
     
    332332        return {True: True, False: False}.get(value, None)
    333333
    334334class ChoiceField(Field):
    335     def __init__(self, choices=(), required=True, widget=Select, label=None, initial=None, help_text=None):
    336         super(ChoiceField, self).__init__(required, widget, label, initial, help_text)
     335    def __init__(self, label=None, choices=(), required=True, widget=Select, initial=None, help_text=None):
     336        super(ChoiceField, self).__init__(label, required, widget, initial, help_text)
    337337        self.choices = choices
    338338
    339339    def _get_choices(self):
     
    365365class MultipleChoiceField(ChoiceField):
    366366    hidden_widget = MultipleHiddenInput
    367367
    368     def __init__(self, choices=(), required=True, widget=SelectMultiple, label=None, initial=None, help_text=None):
    369         super(MultipleChoiceField, self).__init__(choices, required, widget, label, initial, help_text)
     368    def __init__(self, label=None, choices=(), required=True, widget=SelectMultiple, initial=None, help_text=None):
     369        super(MultipleChoiceField, self).__init__(label, choices, required, widget, initial, help_text)
    370370
    371371    def clean(self, value):
    372372        """
Back to Top