summaryrefslogtreecommitdiff
path: root/django/forms
diff options
context:
space:
mode:
authorPeter Andersen <peter@porksmash.com>2019-12-09 08:54:40 -0800
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2019-12-10 12:27:50 +0100
commit02eff7ef60466da108b1a33f1e4dc01eec45c99d (patch)
tree95064bbf996ab878b2217b693c58a734abad5385 /django/forms
parent3fb7c12158a2402f0f80824f6778112071235803 (diff)
Fixed #31073 -- Prevented CheckboxInput.get_context() from mutating attrs.
Diffstat (limited to 'django/forms')
-rw-r--r--django/forms/widgets.py4
1 files changed, 1 insertions, 3 deletions
diff --git a/django/forms/widgets.py b/django/forms/widgets.py
index 6fe220bea7..d83d63c169 100644
--- a/django/forms/widgets.py
+++ b/django/forms/widgets.py
@@ -522,9 +522,7 @@ class CheckboxInput(Input):
def get_context(self, name, value, attrs):
if self.check_test(value):
- if attrs is None:
- attrs = {}
- attrs['checked'] = True
+ attrs = {**(attrs or {}), 'checked': True}
return super().get_context(name, value, attrs)
def value_from_datadict(self, data, files, name):