1
0
mirror of https://github.com/django/django.git synced 2025-11-07 07:15:35 +00:00

Fixed #28795 -- Removed 'not in' checks and used dict.setdefault().

This commit is contained in:
Дилян Палаузов
2017-11-13 16:15:49 -05:00
committed by Tim Graham
parent a2ec1e6b2d
commit 23bf4ad87f
13 changed files with 27 additions and 60 deletions

View File

@@ -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,