diff options
| author | Дилян Палаузов <dilyanpalauzov@users.noreply.github.com> | 2017-11-13 16:15:49 -0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-11-14 10:52:52 -0500 |
| commit | 23bf4ad87f86f44a5ecf9aea722ced76fe7b7fdf (patch) | |
| tree | b6951dcd0887643851803becb4ec608eeab6ba68 /django/forms | |
| parent | a2ec1e6b2d05a1de86a6d02d1e035250b9fefa77 (diff) | |
Fixed #28795 -- Removed 'not in' checks and used dict.setdefault().
Diffstat (limited to 'django/forms')
| -rw-r--r-- | django/forms/boundfield.py | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/django/forms/boundfield.py b/django/forms/boundfield.py index 6acae1c59b..dba54e588a 100644 --- a/django/forms/boundfield.py +++ b/django/forms/boundfield.py @@ -87,20 +87,10 @@ class BoundField: attrs = attrs or {} attrs = self.build_widget_attrs(attrs, widget) - auto_id = self.auto_id - if auto_id and 'id' not in attrs and 'id' not in widget.attrs: - if not only_initial: - attrs['id'] = auto_id - else: - attrs['id'] = self.html_initial_id - - if not only_initial: - name = self.html_name - else: - name = self.html_initial_name - + if self.auto_id and 'id' not in widget.attrs: + attrs.setdefault('id', self.html_initial_id if only_initial else self.auto_id) return widget.render( - name=name, + name=self.html_initial_name if only_initial else self.html_name, value=self.value(), attrs=attrs, renderer=self.form.renderer, |
