Ticket #8169: admin-widgets-attrs.diff

File admin-widgets-attrs.diff, 2.8 KB (added by Alex Gaynor, 16 years ago)
  • django/contrib/admin/widgets.py

    diff --git a/django/contrib/admin/widgets.py b/django/contrib/admin/widgets.py
    index 884171b..5c6353b 100644
    a b class AdminDateWidget(forms.TextInput):  
    3939        js = (settings.ADMIN_MEDIA_PREFIX + "js/calendar.js",
    4040              settings.ADMIN_MEDIA_PREFIX + "js/admin/DateTimeShortcuts.js")
    4141       
    42     def __init__(self, attrs={}):
     42    def __init__(self, attrs=None):
    4343        super(AdminDateWidget, self).__init__(attrs={'class': 'vDateField', 'size': '10'})
    4444
    4545class AdminTimeWidget(forms.TextInput):
    class AdminTimeWidget(forms.TextInput):  
    4747        js = (settings.ADMIN_MEDIA_PREFIX + "js/calendar.js",
    4848              settings.ADMIN_MEDIA_PREFIX + "js/admin/DateTimeShortcuts.js")
    4949
    50     def __init__(self, attrs={}):
     50    def __init__(self, attrs=None):
    5151        super(AdminTimeWidget, self).__init__(attrs={'class': 'vTimeField', 'size': '8'})
    5252   
    5353class AdminSplitDateTime(forms.SplitDateTimeWidget):
    class AdminFileWidget(forms.FileInput):  
    7979    """
    8080    A FileField Widget that shows its current value if it has one.
    8181    """
    82     def __init__(self, attrs={}):
     82    def __init__(self, attrs=None):
    8383        super(AdminFileWidget, self).__init__(attrs)
    8484       
    8585    def render(self, name, value, attrs=None):
    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        if attrs is None:
     215            attrs = {}
     216        super(AdminTextareaWidget, self).__init__(attrs=attrs.update({'class': 'vLargeTextField'}))
    215217
    216218class AdminTextInputWidget(forms.TextInput):
    217     def __init__(self, attrs={}):
    218         super(AdminTextInputWidget, self).__init__(attrs={'class': 'vTextField'})
     219    def __init__(self, attrs=None):
     220        if attrs is None:
     221            attrs = {}
     222        super(AdminTextInputWidget, self).__init__(attrs=attrs.update({'class': 'vTextField'}))
    219223
    220224class AdminURLFieldWidget(forms.TextInput):
    221     def __init__(self, attrs={}):
    222         super(AdminURLFieldWidget, self).__init__(attrs={'class': 'vURLField'})
     225    def __init__(self, attrs=None):
     226        if attrs is None:
     227            attrs = {}
     228        super(AdminURLFieldWidget, self).__init__(attrs=attrs.update({'class': 'vURLField'}))
    223229
    224230class AdminIntegerFieldWidget(forms.TextInput):
    225     def __init__(self, attrs={}):
    226         super(AdminIntegerFieldWidget, self).__init__(attrs={'class': 'vIntegerField'})
    227  No newline at end of file
     231    def __init__(self, attrs=None):
     232        if attrs is None:
     233            attrs = {}
     234        super(AdminIntegerFieldWidget, self).__init__(attrs=attrs.update({'class': 'vIntegerField'}))
Back to Top