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

Fixed #28982 -- Simplified code with and/or.

This commit is contained in:
Дилян Палаузов
2018-01-03 18:52:12 -05:00
committed by Tim Graham
parent c2d0f8c084
commit d7b2aa24f7
55 changed files with 98 additions and 218 deletions

View File

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

View File

@@ -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):