From 1c9ca83db2a73e8eb920fb50a2f1ee9a8228bcbf Mon Sep 17 00:00:00 2001 From: Brian Rosner Date: Fri, 8 Aug 2008 21:27:03 +0000 Subject: [PATCH] Fixed #8169 -- Honor attrs from subclasses of the new admin widgets introduced in [8240]. Thanks Alex Gaynor for the patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8247 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/contrib/admin/widgets.py | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/django/contrib/admin/widgets.py b/django/contrib/admin/widgets.py index 02a52702d3..96b81151a6 100644 --- a/django/contrib/admin/widgets.py +++ b/django/contrib/admin/widgets.py @@ -210,17 +210,29 @@ class RelatedFieldWidgetWrapper(forms.Widget): return self.widget.id_for_label(id_) class AdminTextareaWidget(forms.Textarea): - def __init__(self, attrs={}): - super(AdminTextareaWidget, self).__init__(attrs={'class': 'vLargeTextField'}) + def __init__(self, attrs=None): + final_attrs = {'class': 'vLargeTextField'} + if attrs is not None: + final_attrs.update(attrs) + super(AdminTextareaWidget, self).__init__(attrs=final_attrs}) class AdminTextInputWidget(forms.TextInput): - def __init__(self, attrs={}): - super(AdminTextInputWidget, self).__init__(attrs={'class': 'vTextField'}) + def __init__(self, attrs=None): + final_attrs = {'class': 'vTextField'} + if attrs is not None: + final_attrs.update(attrs) + super(AdminTextInputWidget, self).__init__(attrs=final_attrs) class AdminURLFieldWidget(forms.TextInput): - def __init__(self, attrs={}): - super(AdminURLFieldWidget, self).__init__(attrs={'class': 'vURLField'}) + def __init__(self, attrs=None): + final_attrs = {'class': 'vURLField'} + if attrs is not None: + final_attrs.update(attrs) + super(AdminURLFieldWidget, self).__init__(attrs=final_attrs) class AdminIntegerFieldWidget(forms.TextInput): - def __init__(self, attrs={}): - super(AdminIntegerFieldWidget, self).__init__(attrs={'class': 'vIntegerField'}) \ No newline at end of file + def __init__(self, attrs=None): + final_attrs = {'class': 'vIntegerField'} + if attrs is not None: + final_attrs.update(attrs) + super(AdminIntegerFieldWidget, self).__init__(attrs=final_attrs)