Ticket #8169: admin-widgets-attrs.4.diff

File admin-widgets-attrs.4.diff, 1.8 KB (added by Alex Gaynor, 16 years ago)

This patch is so good your brain will explode(fixed an inconsistancy)

  • django/contrib/admin/widgets.py

    diff --git a/django/contrib/admin/widgets.py b/django/contrib/admin/widgets.py
    index 884171b..f45ff36 100644
    a b class RelatedFieldWidgetWrapper(forms.Widget):  
    210210        return self.widget.id_for_label(id_)
    211211
    212212class AdminTextareaWidget(forms.Textarea):
    213     def __init__(self, attrs={}):
    214         super(AdminTextareaWidget, self).__init__(attrs={'class': 'vLargeTextField'})
     213    def __init__(self, attrs=None):
     214        final_attrs = {'class': 'vLargeTextField'}
     215        if attrs is not None:
     216            final_attrs.update(attrs)
     217        super(AdminTextareaWidget, self).__init__(attrs=final_attrs})
    215218
    216219class AdminTextInputWidget(forms.TextInput):
    217     def __init__(self, attrs={}):
    218         super(AdminTextInputWidget, self).__init__(attrs={'class': 'vTextField'})
     220    def __init__(self, attrs=None):
     221        final_attrs = {'class': 'vTextField'}
     222        if attrs is not None:
     223            final_attrs.update(attrs)
     224        super(AdminTextInputWidget, self).__init__(attrs=final_attrs)
    219225
    220226class AdminURLFieldWidget(forms.TextInput):
    221     def __init__(self, attrs={}):
    222         super(AdminURLFieldWidget, self).__init__(attrs={'class': 'vURLField'})
     227    def __init__(self, attrs=None):
     228        final_attrs = {'class': 'vURLField'}
     229        if attrs is not None:
     230            final_attrs.update(attrs)
     231        super(AdminURLFieldWidget, self).__init__(attrs=final_attrs)
    223232
    224233class AdminIntegerFieldWidget(forms.TextInput):
    225     def __init__(self, attrs={}):
    226         super(AdminIntegerFieldWidget, self).__init__(attrs={'class': 'vIntegerField'})
     234    def __init__(self, attrs=None):
     235        final_attrs = {'class': 'vIntegerField'}
     236        if attrs is not None:
     237            final_attrs.update(attrs)
     238        super(AdminIntegerFieldWidget, self).__init__(attrs=final_attrs)
Back to Top