diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2018-02-26 18:23:31 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-02-26 18:23:31 +0100 |
| commit | 074a2f7f58cfab807ae72b09e634cad30a895369 (patch) | |
| tree | 36c3b4f87c2465e9e4b78a5b0c7b99d5a90b0070 /django/forms/widgets.py | |
| parent | 5b589a47b9ac2c8bdd13ba837fea37991a1457b9 (diff) | |
Refs #28909 -- Simplifed code using unpacking generalizations.
Diffstat (limited to 'django/forms/widgets.py')
| -rw-r--r-- | django/forms/widgets.py | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/django/forms/widgets.py b/django/forms/widgets.py index c0e3349aba..f3a6b38f46 100644 --- a/django/forms/widgets.py +++ b/django/forms/widgets.py @@ -958,35 +958,29 @@ class SelectDateWidget(Widget): year_choices = [(i, str(i)) for i in self.years] if not self.is_required: year_choices.insert(0, self.year_none_value) - year_attrs = context['widget']['attrs'].copy() year_name = self.year_field % name - year_attrs['id'] = 'id_%s' % year_name date_context['year'] = self.select_widget(attrs, choices=year_choices).get_context( name=year_name, value=context['widget']['value']['year'], - attrs=year_attrs, + attrs={**context['widget']['attrs'], 'id': 'id_%s' % year_name}, ) month_choices = list(self.months.items()) if not self.is_required: month_choices.insert(0, self.month_none_value) - month_attrs = context['widget']['attrs'].copy() month_name = self.month_field % name - month_attrs['id'] = 'id_%s' % month_name date_context['month'] = self.select_widget(attrs, choices=month_choices).get_context( name=month_name, value=context['widget']['value']['month'], - attrs=month_attrs, + attrs={**context['widget']['attrs'], 'id': 'id_%s' % month_name}, ) day_choices = [(i, i) for i in range(1, 32)] if not self.is_required: day_choices.insert(0, self.day_none_value) - day_attrs = context['widget']['attrs'].copy() day_name = self.day_field % name - day_attrs['id'] = 'id_%s' % day_name date_context['day'] = self.select_widget(attrs, choices=day_choices,).get_context( name=day_name, value=context['widget']['value']['day'], - attrs=day_attrs, + attrs={**context['widget']['attrs'], 'id': 'id_%s' % day_name}, ) subwidgets = [] for field in self._parse_date_fmt(): |
