diff options
| author | Peter Andersen <peter@porksmash.com> | 2019-12-09 08:54:40 -0800 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-12-11 09:38:49 +0100 |
| commit | f33be1e8ae2efbca5f209e2365fa35c2aaee340c (patch) | |
| tree | ddfba23bf5a4e53d0b6f255b8d84ee95ca14bfff /django/forms/widgets.py | |
| parent | e8b0903976077b951795938b260211214ed7fe41 (diff) | |
[2.2.x] Fixed #31073 -- Prevented CheckboxInput.get_context() from mutating attrs.
Backport of 02eff7ef60466da108b1a33f1e4dc01eec45c99d from master
Diffstat (limited to 'django/forms/widgets.py')
| -rw-r--r-- | django/forms/widgets.py | 4 |
1 files changed, 1 insertions, 3 deletions
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): |
