From 03e194e6474523c020d4c25797202beaf95a4bba Mon Sep 17 00:00:00 2001 From: Marek Filip Date: Mon, 3 Jun 2024 15:10:14 +0200 Subject: [PATCH] Made translation maps consistent in NullBooleanSelect widget `format_value` should be consistent with `value_from_datadict` method. Translation map options "True" and "False" were missing from the `format_value` method. This change ensures consistency of use between the methods, as well as practical passing of "True" value to the widget when rendering. --- django/forms/widgets.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/django/forms/widgets.py b/django/forms/widgets.py index 4fae110d5e..3a22fb6119 100644 --- a/django/forms/widgets.py +++ b/django/forms/widgets.py @@ -808,6 +808,8 @@ class NullBooleanSelect(Select): return { True: "true", False: "false", + "True": "true", + "False": "false", "true": "true", "false": "false", # For backwards compatibility with Django < 2.2. @@ -821,9 +823,9 @@ class NullBooleanSelect(Select): value = data.get(name) return { True: True, + False: False, "True": True, "False": False, - False: False, "true": True, "false": False, # For backwards compatibility with Django < 2.2.