summaryrefslogtreecommitdiff
path: root/django/forms
diff options
context:
space:
mode:
Diffstat (limited to 'django/forms')
-rw-r--r--django/forms/boundfield.py16
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,