summaryrefslogtreecommitdiff
path: root/django/forms
diff options
context:
space:
mode:
authorДилян Палаузов <Dilyan.Palauzov@db.com>2018-01-12 09:05:16 -0500
committerTim Graham <timograham@gmail.com>2018-01-12 12:44:50 -0500
commita38ae914d89809aed6d79337b74a8b31b6d3849a (patch)
tree42a8465e37fc02b70d8d3f876d23947acb1a2455 /django/forms
parent4bcec02368b7e5466f64dc17286689b16613c94b (diff)
Fixed #28996 -- Simplified some boolean constructs and removed trivial continue statements.
Diffstat (limited to 'django/forms')
-rw-r--r--django/forms/models.py5
-rw-r--r--django/forms/widgets.py3
2 files changed, 3 insertions, 5 deletions
diff --git a/django/forms/models.py b/django/forms/models.py
index 727cdb814a..c546b3972a 100644
--- a/django/forms/models.py
+++ b/django/forms/models.py
@@ -587,9 +587,8 @@ class BaseModelFormSet(BaseFormSet):
return field.to_python
def _construct_form(self, i, **kwargs):
- pk_required = False
- if i < self.initial_form_count():
- pk_required = True
+ pk_required = i < self.initial_form_count()
+ if pk_required:
if self.is_bound:
pk_key = '%s-%s' % (self.add_prefix(i), self.model._meta.pk.name)
try:
diff --git a/django/forms/widgets.py b/django/forms/widgets.py
index c20c8f1b50..27ac88b852 100644
--- a/django/forms/widgets.py
+++ b/django/forms/widgets.py
@@ -599,8 +599,7 @@ class ChoiceWidget(Widget):
str(subvalue) in value and
(not has_selected or self.allow_multiple_selected)
)
- if selected and not has_selected:
- has_selected = True
+ has_selected |= selected
subgroup.append(self.create_option(
name, subvalue, sublabel, selected, index,
subindex=subindex, attrs=attrs,