diff options
| author | Дилян Палаузов <Dilyan.Palauzov@db.com> | 2018-01-03 18:52:12 -0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-01-03 20:12:23 -0500 |
| commit | d7b2aa24f75434c2ce50100cfef3586071e0747a (patch) | |
| tree | 9074eb7522888e744f948c52174f367a4281c200 /django/forms | |
| parent | c2d0f8c084456b5073252a91eeb09ab3d7453b18 (diff) | |
Fixed #28982 -- Simplified code with and/or.
Diffstat (limited to 'django/forms')
| -rw-r--r-- | django/forms/boundfield.py | 8 | ||||
| -rw-r--r-- | django/forms/fields.py | 6 |
2 files changed, 3 insertions, 11 deletions
diff --git a/django/forms/boundfield.py b/django/forms/boundfield.py index 27e80c65e7..d0ddd9715b 100644 --- a/django/forms/boundfield.py +++ b/django/forms/boundfield.py @@ -79,12 +79,9 @@ class BoundField: attributes passed as attrs. If a widget isn't specified, use the field's default widget. """ - if not widget: - widget = self.field.widget - + widget = widget or self.field.widget if self.field.localize: widget.is_localized = True - attrs = attrs or {} attrs = self.build_widget_attrs(attrs, widget) if self.auto_id and 'id' not in widget.attrs: @@ -219,8 +216,7 @@ class BoundField: return data def build_widget_attrs(self, attrs, widget=None): - if not widget: - widget = self.field.widget + widget = widget or self.field.widget attrs = dict(attrs) # Copy attrs to avoid modifying the argument. if widget.use_required_attribute(self.initial) and self.field.required and self.form.use_required_attribute: attrs['required'] = True diff --git a/django/forms/fields.py b/django/forms/fields.py index 61f5ccfe58..2019a43c73 100644 --- a/django/forms/fields.py +++ b/django/forms/fields.py @@ -591,11 +591,7 @@ class FileField(Field): return data def has_changed(self, initial, data): - if self.disabled: - return False - if data is None: - return False - return True + return not self.disabled and data is not None class ImageField(FileField): |
