From f33be1e8ae2efbca5f209e2365fa35c2aaee340c Mon Sep 17 00:00:00 2001 From: Peter Andersen Date: Mon, 9 Dec 2019 08:54:40 -0800 Subject: [2.2.x] Fixed #31073 -- Prevented CheckboxInput.get_context() from mutating attrs. Backport of 02eff7ef60466da108b1a33f1e4dc01eec45c99d from master --- django/forms/widgets.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'django') diff --git a/django/forms/widgets.py b/django/forms/widgets.py index e944091f0d..8cd33c439a 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): -- cgit v1.3