summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2017-04-15 13:01:38 -0400
committerTim Graham <timograham@gmail.com>2017-04-17 08:56:15 -0400
commit844ae40a7cdcb1738ca3a2e8f13bb6b8c2e22efd (patch)
tree41cea31c91366c29bd1f985aca02bdf2471e937e /django
parent91bbe7b1c1da16d51ec35a307762526c026b093a (diff)
[1.11.x] Fixed #28058 -- Restored empty BoundFields evaluating to True.
Regression in b52c73008a9d67e9ddbb841872dc15cdd3d6ee01 Backport of c09bf8d76770d39a4d9545b67598cd05adee281b from master
Diffstat (limited to 'django')
-rw-r--r--django/forms/boundfield.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/django/forms/boundfield.py b/django/forms/boundfield.py
index a1063b2b05..a8e81afe9b 100644
--- a/django/forms/boundfield.py
+++ b/django/forms/boundfield.py
@@ -57,6 +57,13 @@ class BoundField(object):
for widget in self.field.widget.subwidgets(self.html_name, self.value(), attrs=attrs)
)
+ def __bool__(self):
+ # BoundField evaluates to True even if it doesn't have subwidgets.
+ return True
+
+ def __nonzero__(self): # Python 2 compatibility
+ return type(self).__bool__(self)
+
def __iter__(self):
return iter(self.subwidgets)